Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show RowDetails on double-click in WPF DataGrid

At the moment my DataGrid shows the RowDetails when i click a row. But I want to show the RowDetails only on Double-click.

Any ideas for solving this problem?

Thank you!

like image 306
rakete Avatar asked May 25 '11 11:05

rakete


1 Answers

e.g.

<DataGrid RowDetailsVisibilityMode="Collapsed">
    <DataGrid.RowStyle>
        <Style TargetType="{x:Type DataGridRow}">
            <EventSetter Event="MouseDoubleClick" Handler="RowDoubleClick"/>
        </Style>
    </DataGrid.RowStyle>
</DataGrid>
private void RowDoubleClick(object sender, RoutedEventArgs e)
{
    var row = (DataGridRow)sender;
    row.DetailsVisibility = row.DetailsVisibility == Visibility.Collapsed ?
        Visibility.Visible : Visibility.Collapsed;
}
like image 79
H.B. Avatar answered Nov 10 '22 16:11

H.B.