简体   繁体   中英

WPF How to refresh data on the Main Form MainWindow.xaml

I inherited a WPF application that someone else wrote. I have some familiarity with xaml forms from having written a Silverlight application about a year ago. 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. One of these changes some of the data in the Main form. 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:

<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. I would know what to do it a Windows form application but not a WPF application.

If it helps, this used a Telerik grid:

<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. You do not need to modify the App... However, I would recommend reading up on WPF Binding --> Data Binding Overview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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