I was wandering and internet, searching some c# code for WPF that would show like win32 does a Modal Window.
I saw the considerations of Karl and his tabbed stuff. Yet it's not I was looking for. Indeed I really want to create a really easy user-friendly interface for lazy users (that means no tabs!).
I just found a sample of Modal Window on WPF by Mitsu at http://blogs.msdn.com/mitsu/archive/2007/05/07/how-to-simulate-modal-windows-inside-a-single-wpf-window-using-anonymous-methods.aspx.
I would like you guys to take a look and make your evaluation about if is it good or a bad approach to show modal window in you WPF Application!
At first, in large applications modal windows, can be shown from background threads. But in WPF you can create UI elements, only in STA thread. Actually, modal window must block main window and other opened windows.
For accessing STA thread from other threads you should use this: "Application.Current.Dispatcher.Invoke" (Application always start in STA thread), then for blocking all windows set Owner property in popup win to the main window.
Example. Create some window, which will be used as popup, f.e. DialogBox. Start it in the STA thread, and set Owner property:
public static void ShowMessage(string message)
DialogBox dialogBox = new DialogBox(message);
dialogBox.Owner = Application.Current.MainWindow;
You can use this static method from any thread, any place in your application.
That works properly for me
Hope this helps )