我遇到了在其中一个字段中托管 XamComboBox 的 XamDataGrid 的问题。如果用户使用鼠标将焦点放在组合框列中,然后使用键盘上的字母选择一个项目,然后按 Tab 键移动到下一列,则组合中的选择将丢失。
我不确定这是控件中的错误还是我使用它们的方式,我试图通过使用 CellDeactivating 事件来解决这个问题,但我认为那个值已经丢失了. 我正在使用版本 11.2.20112.2316 的控件。我也将此发布到Infragistics 论坛。
这一点 XAML 和代码隐藏演示了这个问题。
<Window x:Class="DataGridTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ig="http://infragistics.com/DataPresenter"
xmlns:igEditors="http://infragistics.com/Editors"
Title="MainWindow" Height="350" Width="525">
<ig:XamDataGrid DataSource="{Binding MyData}" >
<ig:XamDataGrid.FieldLayoutSettings>
<ig:FieldLayoutSettings AllowAddNew="True" AutoGenerateFields="False" />
</ig:XamDataGrid.FieldLayoutSettings>
<ig:XamDataGrid.FieldLayouts>
<ig:FieldLayout>
<ig:Field Name="Code">
<ig:Field.Settings>
<ig:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<ig:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ValuePath" Value="Code" />
<Setter Property="DisplayMemberPath" Value="Description"/>
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=MyData2}" />
</Style>
</ig:FieldSettings.EditorStyle>
</ig:FieldSettings>
</ig:Field.Settings>
</ig:Field>
<ig:Field Name="Description"></ig:Field>
</ig:FieldLayout>
</ig:XamDataGrid.FieldLayouts>
</ig:XamDataGrid>
</Window>
-
using System;
using System.ComponentModel;
using System.Windows;
namespace DataGridTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MyData = new BindingList<MyModel>
{
new MyModel {Code = "T1", Description = "Test 1"},
new MyModel {Code = "T2", Description = "Test 2"}
};
MyData2 = new BindingList<MyModel>
{
new MyModel {Code = "T1", Description = "Test 3"},
new MyModel {Code = "T2", Description = "Test 4"}
};
DataContext = this;
}
public BindingList<MyModel> MyData { get; set; }
public BindingList<MyModel> MyData2 { get; set; }
}
public class MyModel
{
public string Code { get; set; }
public string Description { get; set; }
}
}