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

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.