Export (0) Print
Expand All

DataGrid.GridLinesVisibility Property

Gets or sets a value that indicates which grid lines separating inner cells are shown.

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

public DataGridGridLinesVisibility GridLinesVisibility { get; set; }
<sdk:DataGrid GridLinesVisibility="dataGridGridLinesVisibilityValue"/>

XAML Values

dataGridGridLinesVisibilityValue

A named constant of the DataGridGridLinesVisibility enumeration, such as Horizontal.

Property Value

Type: System.Windows.Controls.DataGridGridLinesVisibility
One of the enumeration values indicating which grid lines are shown. The default is All.

Dependency property identifier field: GridLinesVisibilityProperty

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


private void cbGridLines_SelectionChanged(object sender, RoutedEventArgs e)
{
    ComboBoxItem cbi = ((ComboBox)sender).SelectedItem as ComboBoxItem;
    if (this.dataGrid1 != null)
    {
        if (cbi.Content.ToString() == "All")
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.All;
        else if (cbi.Content.ToString() == "Vertical (Default)")
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.Vertical;
        else if (cbi.Content.ToString() == "Horizontal")
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.Horizontal;
        else
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.None;
    }

}


Silverlight

Supported in: 5, 4, 3

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

Community Additions

Show:
© 2014 Microsoft