0

In my VSPackage I have an event handler for the WindowActivated event on the EnvDTE.WindowEvents interface.

In my code I check whether the activated window is WinForms designer with (in VB.NET)

If TypeOf GotFocus.Object Is IDesignerHost Then
  ...
End if

or an ASP designer window with

If TypeOf GotFocus.Object Is EnvDTE.HTMLWindow Then
  ...
End if

What is the best way to detect when a XAML designer window is activated?

Of course, I can check the file extension in the caption (GotFocus.Caption), but I wondered if there was a better way.

Phil Jollans
  • 3,605
  • 2
  • 37
  • 50

1 Answers1

0

File extension probably isn't a good idea because you can open a .XAML file with the stock code editor as well :-)

Easiest way I can think of, would be to leverage the IVsMonitorSelection service.

Call GetCmdUIContextCookie with the the XAML Designer context guid {e9b8485c-1217-4277-b6d6-c825a5ac1968} (found with the Component Diagnostics extension ), and then call IsCmdUIContextActive to determine if the designer is activated.

Ed Dore
  • 2,013
  • 1
  • 10
  • 8