WPF and WindowsFormsHost tooltip issues

I place a windowsforms control in a WPF popup. The problems below:

  • If I create StaysOpen = False, I cannot interact with the winform control. StaysOpen for false is required because when you click "Outidet" in the Popup area, it should close.
  • If I create StaysOpen = True, I can interact with the winform control, but when I go outside the pop-up area, it does not close.
  • I tried to set StaysOpen = true in MouseEnter popup and StaysOpen = False in MouseLeave, but MouseLeave is triggered when and when the mouse finished winform control, which leads to unexpected behavior.
  • I even tried the IsMouseCaptureWithin popup window property and found that it does not work with winforms (I think its error is in the framework).

  • Another problem: I tried to close the popup when the main root shape (which is the shape of the window) is deactivated (Alt + Tab is pressed), but this event (deactivate) is fired even when I enter one of the controls in windowshostControl in the popup.

Desired behavior:

  • should be able to host and interact with the winform control in a wpf popup.
  • when you click on the outside of the popup, the popup should close.

Rate any inputs.

Thanks.

+6
wpf popup windowsformshost
source share
2 answers

I had a lot of problems with the standard popups in WPF because they are actually a new window with their own handle. This means that if you drag the application around the screen, the pop-up window remains (it does not move with your window). It also means that your popup has strange behavior and does not interact with your application, as other controls usually do.

I created 2 decorator classes to solve this problem:

PopupDecorator.cs and TimeoutPopupDecorator.cs

It is quite easy to use:

  • Add a namespace declaration for new popup classes. i.e.

    XMLNS: dday_wpf = "CLR Names: DDay.WPF"

  • Surround the area in which you want the popup to be displayed using the decorator. i.e.

    <dday_wpf: PopupDecorator x: Name = "popup"> <dday_wpf: PopupDecorator.Popup> ... the contents of the pop-up window here ... </ dday_wpf: PopupDecorator.Popup> ... the contents of the go here panel ... </ dday_wpf : PopupDecorator>

It works pretty much identical to the normal Popup from now on.

This may not solve all your problems, but hopefully it helps.

+2
source share

This seems like my problem starting a brainless winform control from a WPF form.

Check my question. Why is my WPF "kinda" text block read-only? .

Just a being based on what Doug said about pop-ups being a window with its own handle makes it applicable.

0
source share

All Articles