Export (0) Print
Expand All
Expand Minimize

ScrollBarVisibility Enumeration

Specifies the visibility of a scrollbar within a ScrollViewer control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public Enumeration ScrollBarVisibility
<object property="enumMemberName"/>

Member nameDescription
Supported by Silverlight for Windows PhoneDisabledA 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.
Supported by Silverlight for Windows PhoneAutoA 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.
Supported by Silverlight for Windows PhoneHiddenA 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.
Supported by Silverlight for Windows PhoneVisibleA 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>


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft