1

I have creating a wpf application and in my settings panel I have tons of UI elements. The problem is that when I resize the window some of these elements are not visible anymore. Is there any way to add a simple vertical scrollbar?

I have tried this below and add my content into it :

    <ScrollViewer VerticalScrollBarVisibility="Auto">
       <Grid>
          <StackPanel>
              //Content
          </StackPanel>
       </Grid>
    </ScrollViewer>

I'm not sure if I put the ScrollViewer to the right Place but I got this error :

The member resources is not recognized or is not accessible

and for this error I have tried to replace the Page.Resources with Window.Resources but it did not help.

Anyways how could I get my vertical scrollbar working? Any helps?

TheNewBegining
  • 91
  • 1
  • 14
  • Can you provide details on how you "added" your controls? And I'm not sure if the error you mentioned is related to the `ScrollViewer` itself. Maybe show more code? – janonimus Apr 19 '17 at 05:52

2 Answers2

3

Problem solved by removing the Width and Height properties from the Page.

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Height="800" Width="1400"
      WindowTitle="ScrollViewer Sample">
  <ScrollViewer VerticalScrollBarVisibility="Auto">
     <Grid>
       <StackPanel>
          //Content
       </StackPanel>
     </Grid>
  </ScrollViewer>
</Page>
TheNewBegining
  • 91
  • 1
  • 14
1

You should get rid of the StackPanel. A StackPanel measures its children with an infinite space and therefore it doesn't work very well with scroll bars:

Horizontal scroll for stackpanel doesn't work

Community
  • 1
  • 1
mm8
  • 163,881
  • 10
  • 57
  • 88