CM(Caliburn.Micro)框架绑定DataGridRow事件

       <DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<Setter Property="cm:Message.Attach"
Value="[Event MouseLeftButtonUp] = [Action RowCheckSetting_MouseLeftButtonUp($source,$eventArgs)];[Event KeyUp] = [Action RowCheckSetting_KeyUp($eventArgs)]" />
</Style>
</DataGrid.ItemContainerStyle>

public void RowCheckSetting_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//todo
}

WPF  DataGridRow Event-LMLPHP

EventSetter事件方式处理

    <DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick"
Handler="DataGrid_MouseDoubleClick"></EventSetter>
<Setter Property="cm:Message.Attach"
Value="[Event MouseDoubleClick] = [Action OnSummaryDataGridMouseDoubleClick($source)]" />
</Style>
</DataGrid.ItemContainerStyle>

Handler对应的事件

  private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{ }

上面代码使用CM框架和EventSetter方式处理DataGridRow的双击事件,当然也可以使用其他的Click事件。

05-26 07:59