dsafa/CSDeskBand

[WPF] Using a Window as UIElement

srwi opened this issue · 2 comments

srwi commented

I am trying to use a Window instead of a simple UserControl so I can take advantage of its Activated and Deactivated events. However the deskband does not show.

Steps to reproduce:

  1. Open the WPF sample project
  2. Create a new window Window1
  3. Change line 23 in Deskband.cs to:
    protected override UIElement UIElement => new Window1();

Alternatively, is there any other way to detect if the deskband (including all of its child windows) get deactivated?

dsafa commented

Haven't really played with wpf windows but I think they are a bit different. I know that winforms windows (Forms) work fine. I tried out the steps above and I see that the error is because a window has to be top level and can't be a child. I remember I was able to use a window before though when I was experimenting,
I'll update if I remember.

I also don't know much about the deactivated so that needs some investigation too.

dsafa commented

If you change it so that you get the handle from new WindowInteropHelper(window).Handle it will work.