DrGriff
DrGriff

Reputation: 4906

WPF dialog blocking input after closing

I have a WPF window in a VSIX application that I show as follows:

var myWindow = new MyWindow(this.CurrentWorkspace)
{
    Owner = Application.Current.MainWindow
};
myWindow .ShowDialog();

However, after I've closed this window, I then get the following error message:

Microsoft Visual Studio has detected that an operation is blocking user input. This can be caused by an active modal dialog or a task that needs to block user interaction.

What am I missing?

Note, this may not need to be a dialog window, but I had a problem when it wasn't.

Upvotes: 1

Views: 363

Answers (2)

DrGriff
DrGriff

Reputation: 4906

Found that the DialogWindow solved the problem mentioned, but it wasn't a complete solution. Refer to: WPF modal window in Visual Studio Extension blocking input.

Upvotes: 0

Ed Dore
Ed Dore

Reputation: 2109

I've encountered this a number of times, and the easiest way to avoid this problem is to derive your dialog from Microsoft.VisualStudio.PlatformUI.DialogWindow, to ensure it's properly parented, and the IDE's modal state set accordingly.

Basically, the issue here is that the IDE doesn't really know about your dialog, it could be implemented via Win32/WinForms or WPF, and invoking IVSUIShell.EnableModeless, works for the former, I've never been able to make it work with the latter. So I just derive from the Microsoft.VisualStudio.PlatformUI.DialogWindow and let it handle the details.

Sincerely,

Upvotes: 2

Related Questions