Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Datagrid -hide RowDetails

Tags:

c#

wpf

datagrid

Is there any way to hide the row detail of a WPF DataGrid? I want to show only the row in the data grid.

enter image description here Thanks

<DataGrid ItemsSource="{Binding Path=oExtrationMasterList}" RowHeaderWidth="0" x:Name="DataGridMaster" AreRowDetailsFrozen="True"  HorizontalAlignment="Left" Margin="15,128,0,0" VerticalAlignment="Top" Height="199" Width="614" AutoGenerateColumns="False" SelectionChanged="DataGridMaster_SelectionChanged" RowDetailsVisibilityMode="Collapsed">
        <DataGrid.Columns>
            <DataGridTextColumn Header="ID" Width="30"  Binding="{Binding TransactionDate}" Visibility="Hidden" />
            <DataGridTextColumn Header="Transaction Date" Width="*" Binding="{Binding TransactionDate}" />
            <DataGridTextColumn Header="Transaction Count" Width="*" Binding="{Binding TransactionCount}" />
        </DataGrid.Columns>
    </DataGrid>
like image 608
Sri Avatar asked Jan 27 '13 09:01

Sri


1 Answers

You have to set the RowDetailsVisibilityMode property to Collapsed.

RowDetailsVisibilityMode="Collapsed"

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

In XAML you can set is like bellow:

<sdk:DataGrid RowDetailsVisibilityMode="Collapsed"/>

In C#, you can use this:

myDataGrid.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed;
like image 153
Ionică Bizău Avatar answered Oct 05 '22 22:10

Ionică Bizău