为 GridControl 中的单元格启用就地编辑

Enable in-place edit for cell in GridControl

我想为我的 GridControl 中的单元格启用就地编辑。我已经在 TableView 和 Columns 上设置了 属性 AllowEditing,但是双击单元格后我的单元格中的数据仍然无法编辑。上下文菜单中仅启用 "copy"。我没有找到解决方案。

TableView 中的 NavigationStyle 属性 设置为 "Cell"

我的xaml.

    <dx:PLinqInstantFeedbackDataSource x:Name="PLinqInstantFeedbackDataSource" ListSource="{Binding Path=TestCollectionSource}" DefaultSorting="Property1 ASC"/>
    <dxg:GridControl EnableSmartColumnsGeneration="True" ItemsSource="{Binding Path=Data, ElementName=PLinqInstantFeedbackDataSource}" SelectionMode="Cell" IsManipulationEnabled="True">
        <dxg:GridControl.View>
            <dxg:TableView AllowEditing="True" NavigationStyle="Cell" AllowFilterEditor="True" AlternateRowBackground="CornflowerBlue" ShowAutoFilterRow="True" />
        </dxg:GridControl.View>
        <dxg:GridControl.Columns>
            <dxg:GridColumn FieldName="Property1" AllowEditing="True" ReadOnly="False" />
            <dxg:GridColumn FieldName="Number" AllowEditing="True" ReadOnly="False" />
        </dxg:GridControl.Columns>
    </dxg:GridControl>

编辑

ViewModel 和 ListSource class

public class MainWindowViewModel : ObservableObject
{

    public MainWindowViewModel()
    {

    }

    private BindingList<TestClass> testCollection;
    public BindingList<TestClass> TestCollection
    {
        get
        {
            var result = this.testCollection;
            if (null == result)
            {
                lock(this)
                {
                    result = this.testCollection;
                    if (null == result)
                    {
                        result = new BindingList<TestClass>();
                        for (int i = 0; i < 1000000; i++)
                        {
                            result.Add(new TestClass() { Property1 = "test" + i, Number = i % 20 });
                        }

                        this.testCollection = result;
                    }
                }
            }
            return result;
        }
    }

    public IListSource TestCollectionSource
    {
        get { return new ListSource( ()=> this.TestCollection); }
    }
}
public class ListSource : IListSource
{
    public readonly Func<IList> innerListProvider;
    public ListSource(Func<IList> innerListProvider)
    {
        this.innerListProvider = innerListProvider;
    }
    public IList GetList()
    {
        return this.innerListProvider();
    }

    public bool ContainsListCollection
    {
        get { return false; }
    }
}

public class TestClass : ObservableObject
{
    private string property1;
    public string Property1
    {
        get { return this.property1; }
        set
        {
            this.property1 = value;
            RaisePropertyChanged(() => this.Property1);
        }
    }

    private int number;
    public int Number
    {
        get { return this.number; }
        set
        {
            this.number = value;
            RaisePropertyChanged(() => this.Number);
        }
    }
}

我从 DevExpress 支持那里得到了 answer

PLinqInstantFeedbackDataSource is a read-only data source. If you wish to edit data directly in the grid, bind your source collection to the GridControl.ItemsSource property without using an Instant Feedback data provider.