2013-02-17 75 views
2

我使用WPF DataGrid绑定属性的视图模型来CurrentCell

我想bindCurrentCell的财产的文本(编辑单元),我有我的ViewModel

是否有可能做这个?

编辑:

我试着这样说:

<DataGrid CurrentCell="{Binding MyProp}"...../> 

我得到这个错误:

Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=MyProp; DataItem='MyViewModel' (HashCode=38365672); target element is 'DataGrid' (Name='CustomCmdDg'); target property is 'CurrentCell' (type 'DataGridCellInfo') 

回答

0

OK,它sucssed这样:

<DataGrid CurrentCell="{Binding MyProp, Mode=OneWayToSource}"...../> 
0

我不知道我理解你的问题所在。 但是你可以考虑建立一个标签一个DataTemplate,其内容属性绑定到视图模型属性

+0

是的,问题是,我想绑定属性的当前编辑单元 – 2013-02-17 12:13:39

+0

您是否尝试过这种方式? 2013-02-17 12:15:30

+0

它绑定到所有datagridtextcolumn而不是当前编辑列 – 2013-02-17 12:17:08

相关问题