PopupButton: Control in PopupContent and mouse events

Editors for WPF Forum

Posted 11 years ago by Marcin Szotka
Version: 12.2.0570
Avatar

PopupButton: Controls in PopupContent don't get mouse events. Is there method to change it?

 

Best regards - Marcin Szotka, InstalSoft

Comments (5)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marcin,

Sorry but I don't see that at all.  If I use this snippet I can open the popup with a WPF button on it and I see mouse over effects and clicks just fine:

<shared:PopupButton Content="Test">
	<shared:PopupButton.PopupContent>
		<Button>Test</Button>
	</shared:PopupButton.PopupContent>
</shared:PopupButton>


Actipro Software Support

Posted 11 years ago by Marcin Szotka
Avatar

It is my fault becouse I did not attach example.

Problem I have is connected with WindowsFormsHost. I temporary fixed problem http://www.actiprosoftware.com/community/thread/20577/popupbutton-windowsformshost-in-popupcontent with patch:

public class MyPopupButton : PopupButton
{
   public override void EndInit()
   {
      base.EndInit();
      var popup = (Popup)VisualTreeHelper.GetChild(this, 0);
      var prop = popup.GetType().GetProperty("AllowsTransparency");
      prop.SetValue(popup, false, null);
    }
}

My xaml:

<local:MyPopupButton DisplayMode="PopupOnly">
  <shared:PopupButton.PopupContent>
     <WindowsFormsHost>
       <wf:TreeView Width="320"
                            Height="240"
                            MouseMove="TreeView_MouseMove">
        </wf:TreeView>
     </WindowsFormsHost>
  </shared:PopupButton.PopupContent>
</local:MyPopupButton>

TreeView_MouseMove is not fired.

Answer - Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marcin,

I looked in our PopupButton code and we basically just create a standard Popup and put the content in it.  We don't capture the mouse or anything.  So any mouse capture behavior might be coming from the Popup.

I did some searching and found that it seems that the StaysOpen property on the WPF Popup class causes mouse issues with WindowsFormsHost.  We expose a StaysOpen property on PopupButton that binds to the popup's StaysOpen.  If you set that to true then it will enable mouse events.  But then note that you lose the mouse tracking for clicks outside of the popup.  This appears to be a WPF limitation.


Actipro Software Support

Posted 11 years ago by Marcin Szotka
Avatar

So I wait for next release, actually I patched it in my temporary, derived PopupButton.

Thank you for help and fast replay!

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marcin,

The StaysOpen property I mentioned is already on PopupButton (the version you have).


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.