Problem
A WinForms view is opened as a modal dialog with Form.ShowDialog(IWin32Window owner). After the dialog is shown, it is registered as an io.Connect flyer window with:
Task<IGlueWindow> RegisterWindow(IntPtr handle, GlueWindowOptions options = null, object contextCookie = null)
Instead of staying open, the dialog flickers and closes itself with DialogResult.Cancel, even though the user didn’t interact with it.
Cause
The dialog is first shown as a normal modal dialog via ShowDialog(). RegisterWindow() is then called on the already-open dialog to turn it into a flyer window, and the dialog closes at that point.
Solution
Don’t register a dialog that is already open via ShowDialog(). Show the dialog through the dialog methods on IGlueWindow instead:
Task<T> ShowDialogAsync<T>(IntPtr handle, Func<T> showDialogImpl, GlueDialogOptions options = null);
Task<bool?> ShowWindowDialogAsync<T>(Func<T> windowDialog, GlueDialogOptions options = null) where T : Window;
Task<DialogResult> ShowFormDialogAsync<T>(Func<T> windowDialog, GlueDialogOptions options = null) where T : Form;
bool? ShowDialog(Window window, GlueDialogOptions options = null);
DialogResult ShowDialog(Form form, GlueDialogOptions options = null);
For WinForms, use ShowFormDialogAsync or ShowDialog(Form, GlueDialogOptions).
Example:
if (glueWindow_.ShowDialog(new Form
{
Text = "You sure you want to do this?"
}) == System.Windows.Forms.DialogResult.Cancel)
{
return;
}
Have a question about io.Connect Desktop window management? Post it in the io.Connect Desktop category.