且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

问题我无法刷新datagrid wpf中的数据

更新时间:2023-12-03 15:48:04

对数据使用ObservableCollection( ^ ]).添加或删除项目时,ObservableCollection处理NotifyPropertyChanged.

由于仅看到解决方案的一部分,因此不确定所有内容.您可能需要提供一个适配器,以将您的Queue(?猜您正在使用队列)转换为ObservableCollection.您还可以创建一个控件,该控件执行从ObservableCollection继承的Queue操作所需的操作
Use an ObservableCollection for the data (http://msdn.microsoft.com/en-us/library/ms668604.aspx[^]). The ObservableCollection handles the NotifyPropertyChanged when items are added or deleted.

Since only see part of the solution, so not sure about everything. You may need to provide an adapter to convert your Queue (? guess you are using a queue) to an ObservableCollection. You could also create a control that does what you want as far as Queue operations the inherits from ObservableCollection


尝试此操作..
dataGrid1.BeginEdit();
////////////在这里添加您的代码////////////
dataGrid1.CommitEdit();//或仅使用此
然后刷新datagrid
try this..
dataGrid1.BeginEdit();
///////////add your code here/////////////
dataGrid1.CommitEdit();//or use only this
then refresh datagrid