WPF determines whether the current form is modal 1 and uses System.Windows.Interop.ComponentDispatcher.IsThreadModal to determine the reference: https:// Social.msdn.microsoft.com/forums/vstudio/en-us/c95f1acb-5dee-4670-b779-b07b06afafff/where-is-modal-property? FORUM=WPF Note: reference: Http://stackoverflow.com/questions/368926/how-do-i-determine-if-a-wpf-window-is-modal 1, Wo Rks not immediately after ShowModal is called. Some events still cannot tell if modal 2, this doesn ' t work if a modal dialog are showing this modeless dialog!2, using reflection Eg: Create a new extension method
1 Public Static BOOL Ismodal ( this window window)2{3 return(bool )typeof(Window). GetField ("_showingasdialog", BindingFlags.Instance | BindingFlags.NonPublic). GetValue (window); 4 }
Improvements to:
1 Public Static BOOLIsmodal ( Thiswindow window)2 {3 varfiledinfo=typeof(Window). GetField ("_showingasdialog", BindingFlags.Instance |bindingflags.nonpublic);4 5 returnfiledinfo!=NULL&& (BOOL) filedinfo.getvalue (window);6}
Reference: Http://stackoverflow.com/questions/368926/how-do-i-determine-if-a-wpf-window-is-modal recommend the second kind
WPF determines whether the current form is modal