Tutorial :Window Interaction/Messaging in WPF



Question:

I have two windows, a main window an a window to update the database, the main window displays some data from the database. I have a private variable in main window that is connecting to DataGrid to pass the data, I need to update this private variable with information i entered in the update window. Should I try to access this data in the update window or how would I send a message from update to main to tell main to update it. If that's not clear I can elaborate more.


Solution:1

for me.. i will choose the most natural and cleanest way.

if your update window can be a modal it would be better the main window access its property either then notified to update the data. it will win in automated testing case.

consider this on your main window:

if (updateWindow.ShowDialog() == true)  {     MyUpdatedModel model = updateWindow.MyUpdatedData;  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »