#1,007 – Changing Scrollbar Settings for a ListBox
February 12, 2014 2 Comments
By default, the visibility of both horizontal and vertical scrollbars for a ListBox is set to Auto, indicating that the scrollbars should show up automatically, as needed.
You can change this behavior by setting the value of the ScrollViewer.HorizontalScrollBarVisibility or ScrollViewer.VerticalScrollBarVisibility properties. They can take one of the following values:
- Auto – Scrollbar visible if required
- Visible – Scrollbar always visible
- Hidden – Scrollbar not shown, but content allowed to scroll (e.g. using arrow keys)
- Disabled – Content does not scroll
<ListBox ItemsSource="{Binding ActorList}" Margin="10" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Source="{Binding Image}" Height="100"/> <StackPanel Margin="10,0"> <TextBlock Text="{Binding FullName}" FontWeight="Bold" /> <TextBlock Text="{Binding Dates}"/> <TextBlock Text="{Binding KnownFor}" FontStyle="Italic"/> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>