Reputation: 122412
I'm using Silverlight 4. I have a UserControl
whose LayoutRoot
is wrapped in a ScrollViewer
. I'd like the scroll bar to only appear if the LayoutRoot
overflows the page. It is possible to do it automatically, or should I write code to detect if the content will overflow and set the scrollbar visibility accordingly?
Upvotes: 2
Views: 1433
Reputation: 112795
You should be able to do it automatically using the ScrollViewer.HorizontalScrollBarVisibility
and ScrollViewer.VerticalScrollBarVisibility
properties. Here's a list of all possible values for those properties (the ScrollBarVisibility
enumeration):
I think "Auto" is what you're looking for:
Auto: A ScrollBar appears and the dimension of the ScrollViewer is applied to the content when the viewport cannot display all of the content. For a horizontal ScrollBar, the width of the content is set to the ViewportWidth of the ScrollViewer. For a vertical ScrollBar, the height of the content is set to the ViewportHeight of the ScrollViewer.
Hope this helps!
Upvotes: 4