1

我有以下数据网格:

<DataGrid SelectedItem="{Binding CurrentX}" ColumnWidth="*" ItemsSource="{Binding Model.Xlist, Mode=TwoWay}" AutoGenerateColumns="False">
        <DataGrid.Columns>
      <DataGridTemplateColumn Width="Auto" Header="GO">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Image Width="30" Height="30" Source="../Resources/xx.ico" MouseDown="Image_MouseDown">
                        </Image>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
</DataGrid>

当我单击一行时,单击发生在绑定到 SelectedItem 之前,我希望它以相反的方式进行(首先是绑定,然后是单击事件),

有可能这样做吗?

4

1 回答 1

1

我有类似的问题。使用MouseUp事件:

<my:DataGridTemplateColumn Width="18" CanUserResize="False">
    <my:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Image Width="16" Style="{StaticResource ImageStyle}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseUp">
                        <cmd:EventToCommand Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ShowErrorMessageCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Image>
        </DataTemplate>
    </my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
于 2013-02-11T06:48:04.177 回答