以编程方式双向数据网格 [英] datagrid twoway programmatically
本文介绍了以编程方式双向数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个显示多个表之一的DataGrid:
I have a DataGrid that displays one of several tables:
var db = new XXXXDataContext();
if(....)
dg.ItemsSource = db.tableA;
else
dg.ItemsSource = db.tableB;
这可行,但是不会使用数据库中的更改来更新DataGrid.如何设置
This works, but the DataGrid is not updated with changes in the database. How do I set
the binding mode to TwoWay in code behind?
推荐答案
您所有的数据网格列都应启用TwoWay模式,如下所示:
All of your data grid columns should be TwoWay mode enabled as:
<datagridtextcolumn width="Auto" header="TableAID" binding="{Binding TableACode, Mode=TwoWay, Path=IsSelected, UpdateSourceTrigger=PropertyChanged}" />
这篇关于以编程方式双向数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文