Reputation:
I am hosting windowsforms control in WPF popup. Problems below:
I even tried IsMouseCaptureWithin property of popup and found it does not work with winforms (i guess its a bug in framework).
Another problem, i was trying to close popup when root main form (which is windows form) is deactivated (pressed Alt+Tab), but this event (deactivate) is fired even when i enter into one of the controls in windowshostControl in popup.
Desired Behaviour:
Appreciate any inputs.
Thanks.
Upvotes: 6
Views: 3913
Reputation: 5338
I've had many problems with the defacto-standard popups in WPF, because they are in fact a new window with their own handle. This means if you drag your application around the screen, the popup stays put (it doesn't move with your window). It also means your popup has some strange behaviors and doesn't interact with your application in ways other controls normally do.
I've created 2 decorator classes to address this problem:
PopupDecorator.cs and TimeoutPopupDecorator.cs
It's pretty simple to use:
Add a namespace declaration for the new popup classes. i.e.
xmlns:dday_wpf="clr-namespace:DDay.WPF"
Surround the area you want the popup to be able to be displayed with the decorator. i.e.
<dday_wpf:PopupDecorator x:Name="popup"> <dday_wpf:PopupDecorator.Popup> ... contents of popup go here ... </dday_wpf:PopupDecorator.Popup> ... contents of panel go here ... </dday_wpf:PopupDecorator>
It works pretty much identically to a normal Popup
from that moment on.
This may not solve all your problems, but hopefully it helps.
Upvotes: 2
Reputation: 12530
This sounds a bit like my problem launching a modeless winform control from a WPF form.
Check out my question Why is my WPF textbox "kinda" readonly?.
The just being, based on what Doug said about popups being a window with its own handle, makes this applicable.
Upvotes: 0