ScrollBarVisibility Enumeration
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Specifies the visibility of a scrollbar within a ScrollViewer control.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
| Member name | Description | |
|---|---|---|
| Disabled | A ScrollBar does not appear even when the viewport cannot display all of the content. The dimension of the content is set to the corresponding dimension of the ScrollViewer parent. 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. | |
| 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. | |
| Hidden | A ScrollBar does not appear even when the viewport cannot display all of the content. The dimension of the ScrollViewer is not applied to the content. | |
| Visible | A ScrollBar always appears. The dimension of the ScrollViewer is applied to 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. |
Use this enumeration to set the HorizontalScrollBarVisibility and VerticalScrollBarVisibility property values of the ScrollViewer control.
The member values of this enumeration specify ScrollBar visibility in a given direction. These member values also specify whether the corresponding ScrollViewer dimension is applied to its enclosed content.
When you apply the ViewportWidth or ViewportHeight to ScrollViewer content, you set the viewport size for the content.
The following example shows how to use the ScrollBarVisibility enumeration members to set the HorizontalScrollBarVisibility property of a ScrollViewer control.
<StackPanel> <ScrollViewer HorizontalScrollBarVisibility="Auto"> <Grid VerticalAlignment="Top" HorizontalAlignment="Left"> <Rectangle Fill="LightGray" Width="450" Height="200"></Rectangle> <TextBlock TextWrapping="Wrap" Margin="10,10,10,10"> Auto. Horizontal scroll bars is shown if the content is wider than the viewport.</TextBlock> </Grid> </ScrollViewer> <ScrollViewer HorizontalScrollBarVisibility="Hidden"> <Grid> <Rectangle Fill="LightBlue" Width="550" Height="210" /> <TextBlock TextWrapping="Wrap" Margin="10,10,10,10">Hidden. Horizontal scroll bar is hidden if the content is larger than the viewport, it is not shown.</TextBlock> </Grid> </ScrollViewer> </StackPanel>