Compartilhar via


DataGrid.VerticalScrollBarVisibility Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a value that indicates how the vertical scroll bar is displayed.

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

Syntax

'Declaration
Public Property VerticalScrollBarVisibility As ScrollBarVisibility
public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }
<sdk:DataGrid VerticalScrollBarVisibility="scrollBarVisibilityValue"/>

XAML Values

  • scrollBarVisibilityValue
    A named constant of the ScrollBarVisibility enumeration, such as Disabled.

Property Value

Type: System.Windows.Controls.ScrollBarVisibility
One of the enumeration values that specifies the vertical scroll bar visibility. The default is Auto.

Remarks

Dependency property identifier field: VerticalScrollBarVisibilityProperty

Examples

The following code example demonstrates how to set the VerticalScrollBarVisibility property in code. This example is part of a larger example available in the Walkthrough: Customizing the DataGrid Control Using Properties topic.

Private Sub cbVerticalScroll_Changed(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    Dim cb As CheckBox = sender
    If Me.dataGrid1 IsNot Nothing Then
        If cb.IsChecked = True Then
            Me.dataGrid1.VerticalScrollBarVisibility = ScrollBarVisibility.Visible
        ElseIf cb.IsChecked = False Then
            Me.dataGrid1.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden
        Else
            Me.dataGrid1.VerticalScrollBarVisibility = ScrollBarVisibility.Auto
        End If
    End If
End Sub
private void cbVerticalScroll_Changed(object sender, RoutedEventArgs e)
{
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
    {
        if (cb.IsChecked == true)
            this.dataGrid1.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
        else if (cb.IsChecked == false)
            this.dataGrid1.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
        else 
            this.dataGrid1.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
    }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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

See Also

Reference

Other Resources