[英]WPF How to refresh data on the Main Form MainWindow.xaml
I inherited a WPF application that someone else wrote. 我继承了其他人编写的WPF应用程序。 I have some familiarity with xaml forms from having written a Silverlight application about a year ago.
我大约一年前编写了Silverlight应用程序,对xaml表单有所了解。 But I haven't done a lot with it.
但是我并没有做很多事情。
The Main Window displays a grid. 主窗口显示一个网格。 It then opens up a couple of other xaml forms.
然后,它打开了另外两个xaml形式。 One of these changes some of the data in the Main form.
其中之一更改了Main表单中的某些数据。 If I close the app and reopen it the new data shows.
如果我关闭应用程序并重新打开它,则会显示新数据。 This is ok but I prefer for the grid to dynamically change when the data changes.
可以,但是我希望网格在数据更改时动态更改。 I can't access any of the public properties of the main form.
我无法访问主窗体的任何公共属性。 The main form is open in the app.xaml with the following code:
主表单在app.xaml中使用以下代码打开:
<Application x:Class="NRCME_Client.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
I realize the problem is probably that I have not instanced the Main form, but I don't know how to do this. 我意识到问题可能在于我没有实例化Main表单,但是我不知道该怎么做。 I would know what to do it a Windows form application but not a WPF application.
我会知道该怎么做,但Windows窗体应用程序却不支持WPF应用程序。
If it helps, this used a Telerik grid: 如果有帮助,可以使用Telerik网格:
<telerik:RadGridView x:Name="MainGrid" Margin="0,50,0,0" SelectionMode="Multiple">
<telerik:RadGridView.Columns>
<telerik:GridViewSelectColumn />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
I bind it to the results of a stored procedure: 我将其绑定到存储过程的结果:
mDatabase = new DbGateWay();
clsGlobals.Database = mDatabase;
MainGrid.ItemsSource = clsGlobals.Database.ExecuteSelect("GetAllContacts");
Please help, if you can. 如果可以的话请帮忙。
You should be working with the MainWindow.xaml and .cs files. 您应该使用MainWindow.xaml和.cs文件。 You do not need to modify the App... However, I would recommend reading up on WPF Binding --> Data Binding Overview
您不需要修改App ...但是,我建议您阅读WPF绑定-> 数据绑定概述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.