6

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>
2
  • if I google your question the first hit gives the answer.. :) Commented Jan 27, 2013 at 9:36
  • 1
    after the google search I came across RowDetailsVisibilityMode="Collapsed" , RowHeaderWidth="0", AreRowDetailsFrozen="True" but non of them work. Commented Jan 27, 2013 at 9:37

3 Answers 3

5

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;
Sign up to request clarification or add additional context in comments.

Comments

3

Set RowDetailsVisibilityMode="Collapsed" on your datagrid.

EDIT-

    <DataGrid.RowDetailsTemplate>
        <DataTemplate>                    
        </DataTemplate>
    </DataGrid.RowDetailsTemplate>

4 Comments

I have tried this. But when i click on the row it shows the details as system.data.datarowview
@RV1982 - RowDetailsVisibilityMode="Collapsed" is setting my detail row collapsed. but the arrow on before the first column of the row will expand it with ystem.data.dataRowView.. how do i remove that?
Sample you post seems to work fine for me though. But you can override the RowDeatilsTemplate. Check the edited answer.
Thanks for the answer.. your answer took out the message system.data.dataRowView. it still shows the arrow which can be expand. I think i can live with that :). Thanks
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.