PopupButton: Controls in PopupContent don't get mouse events. Is there method to change it?
Best regards - Marcin Szotka, InstalSoft
PopupButton: Controls in PopupContent don't get mouse events. Is there method to change it?
Best regards - Marcin Szotka, InstalSoft
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>
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.
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.
So I wait for next release, actually I patched it in my temporary, derived PopupButton.
Thank you for help and fast replay!
Hi Marcin,
The StaysOpen property I mentioned is already on PopupButton (the version you have).
Please log in to a validated account to post comments.