简体   繁体   English

刷新 WPF 中的 DataGrid

[英]Refresh DataGrid in WPF

using WPF/C#/Entity Framework.使用 WPF/C#/实体框架。 I have a DataGrid.ItemsSource bound to some ObservableCollection .我有一个绑定到某些ObservableCollectionDataGrid.ItemsSource Now, I add a new item to the collection but DataGrid doesn't refresh.现在,我向集合中添加了一个新项目,但 DataGrid 没有刷新。 I call PropertyChanged as well as view.Refresh() but nothing works.我调用PropertyChanged以及view.Refresh()但没有任何效果。 Please help me.请帮我。

I think the command you are looking for is Datagrid.Items.Refresh()我认为您正在寻找的命令是Datagrid.Items.Refresh()

A common practice to refresh controls that are bound to data is using UpdateTarget() of the binding expression:刷新绑定到数据的控件的常见做法是使用绑定表达式的 UpdateTarget():

BindingOperations.GetBindingExpressionBase(myTextBox, TextBox.TextProperty).UpdateTarget();

Did you try that?你试过吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM