0
我有一個datagrid
其中第一列對所有行都是常量。 我想以下行爲:獨立於行動調用Datagrid單元格的動作
- 當在一行(不包括第一小區)的任何細胞用戶雙擊,
action A
被調用知道選擇了哪個行。這是基於事件(觸發事件)。 - 當用戶雙擊任意行的第一個單元格時,會調用
action B
,知道選擇了哪一行。
要做到這一點,我寫了下面的代碼:
<DataGrid x:Name="dataGrid" ItemsSource="{Binding source}" MouseDoubleClick="doubleClick">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="♣" Foreground="{Binding Path=color}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding FirstCellCommand}" CommandParameter="{Binding SelectedItem, ElementName=dataGrid}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Label" Binding="{Binding label, UpdateSourceTrigger=PropertyChanged}"/>
</DataGrid.Columns>
</DataGrid>
點(1)工作正常,但(2)不觸發動作。
我在這裏錯過了一個觀點嗎?