Check If Controls On another WPF Window Have Been Rendered Using Multithreading
Given you have two WPF windows namely MainWindow and OtherWindow. You basically want to check if the controls in main window have successfully loaded using statements in OtherWindow. The solution is to use Application dispatcher object.
Cheers!
if(Application.Current.Dispatcher.CheckAccess()) { while (true) { foreach (Window window in Application.Current.Windows) { if (window.Title.Equals("Project Title")) { if (window.FindName("your_control") != null) { //do your stuff here... } } } break; } } else { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(CheckMainWindow)); }
Comments
Post a Comment