简体   繁体   English

如何在wpf中刷新窗口?

[英]How Do I refresh window in wpf?

I have a small project I am working on which is a window with 4 WPF tabs on it. 我有一个小项目,我正在做一个窗口,上面有4个WPF标签。

The first tab is where I do most of the work, but occasionally I need to move back to other tabs. 第一个选项卡是我完成大部分工作的地方,但偶尔我需要回到其他选项卡。 One of these tabs has a DataGrid that is bound to a list that is affected by the main tab I stay on. 其中一个选项卡有一个DataGrid,它绑定到受我保留的主选项卡影响的列表。

When I update something on the first tab, I need it to cause a refresh on the data in the Datagrid(usually just to update a value). 当我在第一个选项卡上更新某些内容时,我需要它来刷新Datagrid中的数据(通常只是更新一个值)。

The only way it has been working is if I click on the header myself. 它一直工作的唯一方法是我自己点击标题。

How can I do this in code? 我怎么能在代码中这样做?

Thanks 谢谢

Is the list an ObservableCollection or properties implementing INotifyPropertyChanged ? 列表是ObservableCollection还是实现INotifyPropertyChanged属性?

Have you tried: 你有没有尝试过:

myDatagrid.Items.Refresh();

Maybe: 也许:

this.NavigationService.Refresh();

or 要么

this.NavigationService.Navigate(new Uri("<EnterPage name here.xaml", UriKind.Relative));

If you are working on an Object that you are displaying shared properties you could implement the INotifyPropertyChanged interface and refresh the DataGrid. 如果您正在处理显示共享属性的Object,则可以实现INotifyPropertyChanged接口并刷新DataGrid。 If its a collection you could look at the ObservableCollection class. 如果它是一个集合,你可以查看ObservableCollection类。

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

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