Reputation: 3943
In my xaml, I have some object made by me. I put them in row and, if the window is too little for all, I go in a new line.
The problem is when the window is so little that, also in a new line, the elements can't be all shown. The solution is simple: scroll bar!! But, if I set the Vertical/HorizontalScrollBarVisibility to auto, it doesn't go to a newline anymore.
This is my xaml:
<ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled" >
<ItemsControl Name="ItemGroups" ItemsSource="{Binding NotifyItemUI}" />
</ScrollViewer>
and this is a screenshot what I need as my goal:
For example, if I resize my area vertically, and I have 3 rows of objects, in this way I can't see the third row if the window becames too little. In this case, I'd like to see a vertical scrollbar to scroll it.
Same thing horizontally: if I have too many elements for one single row, I have to scroll it horizontally.
Upvotes: 0
Views: 395
Reputation: 459
What you describe looks like a WrapPanel
, but the way you write about it suggests it is a custom control, so we cannot see what your ItemsControl
is doing for layout.
However, ScrollViewer
can have tricky interaction with a Panel
. If the Panel
measures to infinity, it will always consider itself big enough, and never tell the ScrollViewer
it is out of room. The result is that the ScrollViewer
does no know the scrollbar is needed. If this is your problem, then setting the Width
and Height
properties, or maxima as @Sheridan said, ought to fix it.
Upvotes: 1