XamDataGrid与XamComboEditor不保持选择

时间:2013-09-25 08:32:32

标签: c# wpf infragistics xamdatagrid

我在其中一个字段中托管XamComboBox的XamDataGrid存在问题。如果用户使用鼠标将焦点放入组合框列,然后使用键盘上的字母选择项目,然后按Tab键移动到下一列,则组合中的选择将丢失。

我不确定这是控件中的错误还是我使用它们的方式,我试图通过使用CellDeactivating事件解决问题,但我认为那个价值已经失去了。我正在使用版本11.2.20112.2316的控件。 我还将其发布到Infragistics forums

这一点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; }
    }
}

1 个答案:

答案 0 :(得分:2)

我一直在研究这个问题,看起来XamComboEditor,XamDataGrid和选择存在内部问题。

此处有更多详细信息,请访问Infragistics论坛中的重复论坛帖子:

http://www.infragistics.com/community/forums/p/84127/420015.aspx