Hi,
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
Hi,
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
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.
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
}
}