Show RowDetails on double-click in WPF DataGrid

时间秒杀一切 提交于 2019-12-29 05:56:50

问题


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!


回答1:


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;
}


来源:https://stackoverflow.com/questions/6123748/show-rowdetails-on-double-click-in-wpf-datagrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!