【问题标题】:In infragistics xamdatagrid how to select a row on right click在infragistics xamdatagrid中如何在右键单击时选择一行
【发布时间】:2013-01-28 08:13:24
【问题描述】:

在 XAML 中,我有这段代码

<igDP:FieldLayout.FieldSettings>
    <igDP:FieldSettings AllowRecordFiltering="True" CellClickAction="SelectRecord" AllowEdit="False"/>
</igDP:FieldLayout.FieldSettings>

这里,CellClickAction 用于左键单击。右键单击是否有一些相应的操作以选择记录。我希望记录在左键和右键都被选中

【问题讨论】:

标签: infragistics xamdatagrid


【解决方案1】:

为 DataRecordPresenter(DataRecord 的可视元素)创建一个 Style,其中包含一个类似于 MouseRightButtonDown 事件的 EvenSetter,如下所示:

<Style TargetType="{x:Type igDP:DataRecordPresenter}">
    <EventSetter Event="MouseRightButtonDown" Handler="DataRecordPresenter_MouseRightButtonDown" />
</Style>

并在其事件处理程序中使用此代码 sn-ps:

void DataRecordPresenter_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
    // Clear previous selcted rows        
    (sender as DataRecordPresenter).Record.IsSelected = true;
}

这里有一个问题:如果您继续右键单击不同行中的行/单元格,它会选择多行。所以清除任何先前的选择然后它就会起作用。

【讨论】:

  • 如果dataGrid 是您的网格控件的名称,则要清除的命令是dataGrid.ExecuteCommand(DataPresenterCommands.ClearAllSelected);
猜你喜欢
  • 2022-07-09
  • 1970-01-01
  • 1970-01-01
  • 2012-01-02
  • 2021-08-19
  • 1970-01-01
  • 1970-01-01
  • 2013-08-22
  • 2013-05-21
相关资源
最近更新 更多