无法在datagrid WPF中编辑单元格 [英] cannot edit cell in datagrid WPF

查看:604
本文介绍了无法在datagrid WPF中编辑单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 DataGrid 在我的视图中绑定到一个 ObservableCollection<> 。绑定工作。

I've a DataGrid in my view binded to an ObservableCollection<>. The binding works.

问题是我无法编辑任何单元格,不明白为什么...

The problem is that I cannot edit any cell and don't understand why...

这是我的XAML:

<DataGrid ItemsSource="{Binding ClientSpecifications, Mode=TwoWay}" />

只有这样。而已。但它不行。我正在使用WPF,.NET4,EF。

Only this. Nothing more. But it doesn't work. I'm working with WPF, .NET4, EF.

推荐答案

根据这篇文章:编辑功能概述在WPF DataGrid

datagrid使用 IEditableCollectionView< T> (其中 ObservableCollection< T> implements) - 但为了使对象可编辑,您需要确保对象T已实现 IEditableObject 界面。一旦这样做,Datagrid将会将收藏项目识别为可编辑,并允许您在网格中进行更改。

The datagrid uses IEditableCollectionView<T> (which ObservableCollection<T> implements) - but in order for objects to be editable, you need to make sure that your object T has implemented the IEditableObject Interface. Once you do this, the Datagrid will recognize the collection items as editable and allow you to change them within the grid.

这篇关于无法在datagrid WPF中编辑单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆