DataGrid.RowDetailsVisibilityMode Property

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

Gets or sets a value that indicates when the details sections of rows are displayed.

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

Syntax

'Declaration
Public Property RowDetailsVisibilityMode As DataGridRowDetailsVisibilityMode
public DataGridRowDetailsVisibilityMode RowDetailsVisibilityMode { get; set; }
<sdk:DataGrid RowDetailsVisibilityMode="dataGridRowDetailsVisibilityModeValue"/>

XAML Values

Property Value

Type: System.Windows.Controls.DataGridRowDetailsVisibilityMode
An enumeration value that specifies the visibility of row details. The default is VisibleWhenSelected.

Remarks

Dependency property identifier field: RowDetailsVisibilityModeProperty

Examples

The following code example demonstrates how to set the RowDetailsVisibilityMode property in code. This example is part of a larger example available in the How to: Display and Configure Row Details in the DataGrid Control topic.

' Set the row details visibility to the option selected in the combo box.
Private Sub cbRowDetailsVis_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs)
    Dim cb As ComboBox = sender
    Dim cbi As ComboBoxItem = cb.SelectedItem
    If Me.dataGrid1 IsNot Nothing Then
        If cbi.Content.ToString() = "Selected Row (Default)" Then
            Me.dataGrid1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected
        ElseIf cbi.Content.ToString() = "None" Then
            Me.dataGrid1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed
        ElseIf cbi.Content.ToString() = "All" Then
            Me.dataGrid1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Visible
        End If
    End If
End Sub
// Set the row details visibility to the option selected in the combo box.
private void cbRowDetailsVis_SelectionChanged(object sender, RoutedEventArgs e)
{
    ComboBox cb = sender as ComboBox;
    ComboBoxItem cbi = cb.SelectedItem as ComboBoxItem;
    if (this.dataGrid1 != null)
    {
        if (cbi.Content.ToString() == "Selected Row (Default)")
            dataGrid1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
        else if (cbi.Content.ToString() == "None")
            dataGrid1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed;
        else if (cbi.Content.ToString() == "All")
            dataGrid1.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Visible;
    }
}

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.