Infragistics xam数据网格字段选择器选择

时间:2015-11-12 09:22:22

标签: wpf infragistics xamdatagrid

我对xam数据网格中的字段选择器有一个小问题。 我需要做的是将检查/取消选中行为从双击更改为单击,这在此处完成:

<igWPF:LabelPresenter.InputBindings>
          <MouseBinding Command="{x:Static igWPF:FieldChooserCommands.ToggleVisibility}" MouseAction="LeftDoubleClick" />
        </igWPF:LabelPresenter.InputBindings>

如果我将鼠标操作从左侧双击更改为左键单击,而不是只需要少一次点击,则需要一个以上:两个用于选择字段,另一个用于选中/取消选中。

有什么可以做的,我做错了吗?

1 个答案:

答案 0 :(得分:1)

找到解决这个问题的方法,问题是鼠标左键单击操作已被其他东西使用。

要解决此问题,我们需要删除或评论上面发布的样式部分,并为Label Presenter创建行为。

 public class OneClickFieldVisibility : Behavior<LabelPresenter>
 {
    private LabelPresenter Presenter { get { return this.AssociatedObject; } }

    protected override void OnAttached()
    {
      Presenter.PreviewMouseLeftButtonDown -= Presenter_PreviewMouseLeftButtonDown;
      Presenter.PreviewMouseLeftButtonDown +=  Presenter_PreviewMouseLeftButtonDown;
    }

     void Presenter_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
     {
      var fieldChooser = (FieldChooser)Infragistics.Windows.Utilities.GetAncestorFromType(Presenter, typeof(FieldChooser), false);
      fieldChooser.ExecuteCommand(FieldChooserCommands.ToggleVisibility, Presenter.Field);
      e.Handled = true;
     }
 }
相关问题