This article mainly speaks of the Application.current property. In WPF, we can get access to the main program from anywhere in the application domain through Application.Current.MainWindow. How you want to get the main program in the methods, properties, events, etc., you will need to turn MainWindow into your MainWindow form. The Application.Current.Windows can get the currently open Windows window.
1Window main =Application.Current.MainWindow;2MessageBox.Show ("The main window is"+Main. Title);3 4 5MainWindow main =(MainWindow) Application.Current.MainWindow;6 Main. DoSomething ();7 8 foreach(Window windowinchApplication.Current.Windows)9 {TenMessageBox.Show (window. Title +"is open."); One}
- People who have the ability to influence others, people who are incapable, are affected.
- A wise man has a long ambition, and he who aspires to it
- Diligence is the branches of learning, of course, very bitter, wisdom is learning flowers, of course, fragrant Yu
- Always find time and opportunity to do things, and always find excuses for things you don't want to do.
WPF beginner of the current application instance