Donate

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.
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));  
        }  
Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

Remove Cookies From CookieContainer Class

How To Test Or Check Dead Pixels And Backlight Bleed On Your Monitor Using Dead Pixel Checker In Windows 11