Home > Mobile >  Showing two copy of dialog wpf mvvm
Showing two copy of dialog wpf mvvm

Time:08-03

So I am developing a two-screen application using wpf with mvvm light. I want to mirror them as much as possible. However, I run into problem with the showdialog for windows. Because ShowDialog will put the dialog window into focus and require the user to interact with it first, I cannot create another copy of it on another the second screen. Is there anyway I can create two identical dialog window showing up at the same time?

Thank you so much for your help!

CodePudding user response:

Instead of ShowDialog() use Show() which displays the window in a non-modal way.

CodePudding user response:

May be TaskDialog where the trick to go modeless is IntPtr.Zero for owner parameter. There may be one issue, as shown below the dialog will be center screen while using a third parameter you can set the owner e.g. a button for instance or other control. So this may or may not work for you.

public static void InformationModeless( string heading, string buttonText = "Ok")
{

    TaskDialogButton okayButton = new(buttonText);

    TaskDialogPage page = new()
    {
        Caption = "Information",
        SizeToContent = true,
        Heading = heading,
        Buttons = new TaskDialogButtonCollection() { okayButton }
    };

    TaskDialog.ShowDialog(IntPtr.Zero, page);

}
  • Related