Events 当只有一行时,如何在datagrid中激发SelectionChanged事件

Events 当只有一行时,如何在datagrid中激发SelectionChanged事件,events,xaml,mvvm-light,Events,Xaml,Mvvm Light,当只有一行时,如何在datagrid中触发SelectionChanged事件 例如,我认为: 但是,一旦您选择了一个项目,我就无法重新启动该事件,因为它已被选中。您可能必须依靠单击事件在该事件中为行号添加一个条件。在我的xaml代码中,我有: <i:EventTrigger EventName="SelectionChanged"> <cmd:EventToCommand Command="{Binding myCommand, Mode=OneWay}"

当只有一行时,如何在datagrid中触发SelectionChanged事件

例如,我认为:


但是,一旦您选择了一个项目,我就无法重新启动该事件,因为它已被选中。

您可能必须依靠单击事件在该事件中为行号添加一个条件。

在我的xaml代码中,我有:

<i:EventTrigger EventName="SelectionChanged">
  <cmd:EventToCommand
     Command="{Binding myCommand, Mode=OneWay}"
     CommandParameter="{Binding SelectedItem, ElementName=datagrid}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseLeftButtonDown">
  <cmd:EventToCommand
     Command="{Binding myCommand, Mode=OneWay}"
     CommandParameter="{Binding SelectedItem, ElementName=datagrid}"/>
</i:EventTrigger>