PopupBox is closed after being opened
See original GitHub issueI have a problem with the PopupBox
control where it opens and then closes right away.
I’ve seen this problem for both a simple PopupBox
and a more complex scenario where a custom control has a PopupBox
in its control template. The animation above demonstrates the simple scenario and the XAML for that case looks like this:
<mdt:PopupBox FocusVisualStyle="{x:Null}">
<StackPanel>
<Button Name="ReportProblem" Content="Report Problem..."/>
<Separator/>
<Button Name="Hide" Content="Hide"/>
<Separator/>
<Button Name="Exit" Content="Exit"/>
</StackPanel>
</mdt:PopupBox>
In the complex scenario the content of the PopupBox
has a TextBox
which gets its focus set when the IsPopupOpen
is changed to true. This seems to happen before PopupBox
own change handler which in turn calls AnimateChildrenIn
. The way I do this is through binding IsPopupOpen
to another property which has a property changed handler where the focus is set. I might change to use the Opened/Closed events instead which would make the focus be set “after” PopupBox
handles the property change event.
But still, the behavior is observed even for the simple scenario. That makes me think maybe something else is in play.
The problem is similar to #725 in how it behaves but not how the PopupBox
properties are set. I do not make use of PopupMode="MouseOverEager"
Keeping these notes from @Keboo as a reminder of what try out during troubleshooting:
@mgnslndh thank you. A few additional questions. Are you able to share the contents of your popup box? I am wondering if perhaps some of the timing is coming into play because the AnimateChildrenIn method. I am thinking that perhaps the issue is that it attempts to move mouse capture before those storyboards have been applied. I am not sure I remember your setup exactly, but did you also have the stack trace that was occurring when the popupbox was closing? I am also wondering if perhaps there is some element (like a textbox) that is getting keyboard focus, but then dropping it when the popupbox animates on. As a simple test you might try copying in the existing PopupBox template, and renaming the PART_ to be something else so the control doesn’t find it. This should effectively turn off the animations. Also if you don’t mind opening an issue for this, that would help me keep track of it so this does not get lost.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (9 by maintainers)
@Keboo As mentioned here is the behaviour I see for the dialoghost popup on a touchscreen, 4495 is the DialogHost.AnchorBottom from the MaterialDesignInXaml.Examples solution. 4497 is the same but with the MaterialDesignEmbeddedDialogHost style added to the dialoghost. It seems like the edit box loses focus and the keyboard popup determines it is no longer required and collapses.
1298 Dialog host popup on touch.zip
Ok, @Zangl its nice to have more people on board trying to fix this 😃 I’ve struggled with both issues for a while and finally we might be able to track down the root cause.
@Keboo Anything you want us to try, be sure to let us know.