且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重新选择Datagrid行后,SelectionChanged事件不触发?

更新时间:2023-12-03 13:41:46

仅当选择实际上更改为预期的行为时,才引发 SelectionChanged 事件。

The SelectionChanged event is only supposed to be raised when the selection actually changes to this is the expected behaviour.

您可以尝试处理 DataGridRow PreviewMouseLeftButtonDown 容器:

You could try to handle the PreviewMouseLeftButtonDown of the DataGridRow containers:

<DataGrid ...>
    <DataGrid.ItemContainerStyle>
        <Style TargetType="DataGridRow">
            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="dg_MouseLeftButtonDown"></EventSetter>
        </Style>
    </DataGrid.ItemContainerStyle>
    ...
</DataGrid>