Reputation: 293
Is there any way to hide the row detail of a WPF DataGrid? I want to show only the row in the data grid.
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>
Upvotes: 6
Views: 6275
Reputation: 81233
Set RowDetailsVisibilityMode="Collapsed"
on your datagrid.
EDIT-
<DataGrid.RowDetailsTemplate>
<DataTemplate>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
Upvotes: 3
Reputation: 98740
Try with DataGrid.RowDetailsVisibilityMode
property.
Gets or sets a value that indicates when the details sections of rows are displayed.
DataGridRowDetailsVisibilityMode
enumeration has;
Member name Description
Collapsed The row details section is not displayed for any rows.
Visible The row details section is displayed for all rows.
VisibleWhenSelected The row details section is displayed only for selected rows.
Upvotes: 1
Reputation: 113335
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;
Upvotes: 5