ScrollBarVisibility Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines constants that specify the visibility of a scrollbar within a ScrollViewer control.
public enum class ScrollBarVisibility
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class ScrollBarVisibility
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum ScrollBarVisibility
Public Enum ScrollBarVisibility
<object property="enumMemberName"/>
- Inheritance
-
ScrollBarVisibility
- Attributes
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Fields
Name | Value | Description |
---|---|---|
Disabled | 0 | A ScrollBar does not appear even when the viewport cannot display all of the content. Scrolling is disabled. 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 | 1 | A ScrollBar appears only 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. |
2 | A ScrollBar does not appear even when the viewport cannot display all of the content. Scrolling is still enabled, and can occur through touch, keyboard, or mouse wheel interaction. The dimension of the content is not affected by the dimension of the ScrollViewer. |
|
Visible | 3 | A ScrollBar always appears. 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. |
Examples
The following example shows how to use the ScrollBarVisibility enumeration members to set the HorizontalScrollBarVisibility property of a ScrollViewer control.
<StackPanel Height="400" Width="300">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<Grid VerticalAlignment="Top" HorizontalAlignment="Left">
<Rectangle Fill="Green" Width="450" Height="200"></Rectangle>
<TextBlock Margin="10,10,10,10">
Auto. The horizontal scroll bar is shown if the content is wider than the viewport.
</TextBlock>
</Grid>
</ScrollViewer>
<ScrollViewer HorizontalScrollBarVisibility="Hidden">
<Grid>
<Rectangle Fill="Blue" Width="450" Height="200" />
<TextBlock Margin="10,10,10,10">
Hidden. The horizontal scroll bar is hidden even if the content is wider than the viewport.
</TextBlock>
</Grid>
</ScrollViewer>
</StackPanel>