Export (0) Print
Expand All

DataGridColumn.Visibility Property

Gets or sets the visibility of the column.

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

public Visibility Visibility { get; set; }
<sdk:dataGridColumn Visibility="Visible"/>
-or-
<sdk:dataGridColumn Visibility="Collapsed"/>

XAML Values

sdk:dataGridColumn

Typically, sdk:DataGridTextColumn, sdk:DataGridCheckBoxColumn, or sdk:DataGridTemplateColumn.

Property Value

Type: System.Windows.Visibility
An enumeration value that specifies the column visibility. The default is Visible.

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


private void cbHideColumn_Changed(object sender, RoutedEventArgs e)
{
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
    {
        if (cb.IsChecked == true)
            this.dataGrid1.Columns[0].Visibility = Visibility.Collapsed;
        else if (cb.IsChecked == false)
            this.dataGrid1.Columns[0].Visibility = Visibility.Visible;
    }
}


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

ADD
Show:
© 2014 Microsoft