Reload parent window from a pop-up ("child") window

How it is possible? The idea is to enter info into a form inside a pop-up/child window, and then, as you save/close it, it automatically updates the "Parent" window, from which the pop-up was originally open.

Kindly Suggest,

Thanks

Answers


This is a perfect reason for using the Messenger class in MVVM Light. Create a NotificationMessage to send an update command to the main view model.

    public MainWindowViewModel()
    {
        if ((IsInDesignMode))
        {
        }
        // Code runs in Blend --> create design time data.
        else
        {
            // Code runs "for real"
            Messenger.Default.Register<NotificationMessage<string>>(this, new System.Action<NotificationMessage<string>>(NotificationMessageHandler));

        }
    }

    private void NotificationMessageHandler(NotificationMessage<string> sender)
    {
        if ((sender.Notification == "refreshData"))
        {
            // Do something here
        }
    }

Hope you would be having a ViewModel for the child window. It would be having all the data altered in the ChildWindow. Hence when you close the window, save the corresponding models to the DB and load your MainWindowView model collections again from the DB.


In my app, I have a Singleton object with holds this event:

Public Event DataChanged(ByVal EntityChanged As String, 
                               ByVal IDChanged As Integer)

When a record is saved or deleted, the event is raised (in this case, by the pop-up window)

So all you have to do in the parent window (or in any other window), is subscribe to the event, and refresh the data when event is raised. You can check the EntityChanged param (Product, Order, Customer, etc.) and the ID to see if you must refresh or not.


Need Your Help

Excel's fullname property with OneDrive

excel vba excel-vba onedrive

If I want to use the open Workbook object to get the fullname of an Excel file after saving it, but that file has been synchronized to OneDrive, I get a "https" address instead of a local one, which

How to pass additional parameter with object in Web API,with ajax call?

jquery asp.net-mvc asp.net-web-api

I am using asp.net web api.I am using MVC with that. I am trying to call below ajax call but it alway give me 404 error.