Testing scrollbar visibility in a ListBox encoded

How to check if a vertical scroll bar is visible in the code?

I have a list with x: Name = "listOfItems", and its core function ScrollViewer VerticalScrollbarVisibility is set to auto.

When the ItemsSource property for the ListBox is set, I want to check if the verticalScrollbar is visible, but I don’t know which property to check or how to plunge into the scrollviewer element in the list.

Any suggestions

+4
source share
1 answer

You can find Listbox 'ScrollViewer as described here: WPF - ListBox.ScrollViewer.HorizontalOffset animation?

Then you can use the ComputedVerticalScrollBarVisibility property to check the scroll bar visibility:

ScrollViewer sv = FindVisualChild<ScrollViewer>(listOfItems); Visibility scrollbarVisibility = sv.ComputedVerticalScrollBarVisibility; 
+8
source

All Articles