events - wpf detect open window -
In my WPF app (CSRAP) I have an event handler that will open a new window (window B) when triggered Applications and some data displayed. However, when the event resumes, the new window (window B) is still open, so I do not want to create another instance of Window B, but to update the data displayed in the current instance. So the question is, how is it that the window b is already and if it is not already already open only, otherwise update the data?
I got the application. Present. But in some way that is not working for me yet, you can create a LoadWindow () method in WindowB, which you can call to load (or refresh) << div class = "text- Post "itemprop =" text ">
) data & amp; Whether a window is already open or not, whether it works when this window closes, does it take a representative to call:
Private operation ParentCallbackOnClose; Public Zero LoadWindows (Action ParentsCallbackOnclosus) {// Load data (Data contact or whatever set up) ParentCalbackOnocos = ParentCalback Onocos; // Open the window and Show / Show Show Foreground (); Active (); }
and call off the representative when your window is closed:
Private Zero WindowsClosed (Object Sender, EventArgs e) {ParentCallbackOnClose.Invoke () ; }
Now, which window b opens from your class, it has to be grabbed when it is on, so that the window is already open, when someone tries to reload it , Then it just calls LoadVondow current example something like this ...
Private window B WinB; Private Zero LoadWindowB (content content) {if (WinB == empty) {WinB = new WindowB (); } WinB.LoadWindow (Content, WindowBCLOS); }
And then you can take WinB out of the callback near it so that WinB closes, next time LoadWindowB () will be made a new example:
< Former> private section windowBClosed () {WinB = null; }
Comments
Post a Comment