Reputation: 91
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?
Upvotes: 1
Views: 4544
Reputation: 169400
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
Upvotes: 1
Reputation: 91
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>
Upvotes: 3