MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.09k stars 3.42k forks source link

popup won't stay if PopupMode="MouseOver" and StaysOpen="True" #733

Open issam1975 opened 7 years ago

issam1975 commented 7 years ago

this simple markup illustrate the issue

 <materialDesign:PopupBox HorizontalAlignment="Center"
                                 PlacementMode="TopAndAlignCentres"
                                 PopupMode="MouseOver"
                                 StaysOpen="True">
            <materialDesign:PopupBox.PopupContent>
                <ListBox >
                    <ListBoxItem>A</ListBoxItem>
                    <ListBoxItem>B</ListBoxItem>
                </ListBox>
            </materialDesign:PopupBox.PopupContent>

            <materialDesign:PopupBox.ToggleContent>
                <materialDesign:Badged Badge="2"
                                       x:Name="MainMenuButton"
                                       VerticalAlignment="Stretch"
                                       HorizontalAlignment="Center">
                    <Button 
                            Height="50"
                            VerticalAlignment="Stretch" />
                </materialDesign:Badged>
            </materialDesign:PopupBox.ToggleContent>
        </materialDesign:PopupBox>

as soon i leave the trigger button the popup hide so i cannot select an option from the listbox .

and here a gif showing how it looks : issue

issam1975 commented 7 years ago

any idea on how to fix this , or idea on where to investigate please ?

this is something very critical to my app :p

Keboo commented 7 years ago

@issam1975 I suspect your issue is right here. Basically is the MouseOver popup mode when the mouse leaves it closes the popup. You will notice that if you carefully move your mouse over the badge and then onto the popup you can get it to stay open (only because your mouse never actually leaves the popup).

I suspect the fix will be to actually take the StaysOpen flag into account in that method (but would need to test further to be sure).

issam1975 commented 7 years ago

hi @Keboo : thanks for the suggestion but unfortunally it didn't work .

to be honest i have just modified it like this

  protected override void OnMouseLeave(MouseEventArgs e)
        {
            /*
            if (PopupMode == PopupBoxPopupMode.MouseOverEager
                || PopupMode == PopupBoxPopupMode.MouseOver)

                Close();
            */
            base.OnMouseEnter(e);
        }

but it produce another wrong behaviour the popup no longer close even if i click outside the control . the only way is to select an item from the listbox wich is inside the popupbox .

also and based on your observation i have tried to reset the vertical offset property at runtime so there is no margin between the trigger button and the popup , but with no effect .please see attached files 1 2

any other idea is more than welcome .