Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MenuItem with SubmenuHeaderTemplate - Popup invalid positioning #1322

Open
alex-lapuka opened this issue Jan 27, 2025 · 0 comments
Open

MenuItem with SubmenuHeaderTemplate - Popup invalid positioning #1322

alex-lapuka opened this issue Jan 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@alex-lapuka
Copy link

alex-lapuka commented Jan 27, 2025

Describe the bug

The placement for the sub-items in the ContextMenu works incorrectly if the popup is displayed above the parent control. This happens because of the DropShadowEffect that is added to the child item popup and requires some offsets and margins to be aligned. This works fine in cases when the popup is placed below the parent element.

To Reproduce

I've added the following ContextMenu to the Gallery app NotifyIcon:

   <tray:NotifyIcon
        Grid.Row="0"
        FocusOnLeftClick="True"
        Icon="pack://application:,,,/Assets/wpfui.png"
        MenuOnRightClick="True"
        TooltipText="WPF UI Gallery">
        <tray:NotifyIcon.Menu>
            <ContextMenu>
                <MenuItem Header="Item 1">
                    <MenuItem Header="Item 1.1"/>
                    <MenuItem Header="Item 1.2"/>
                </MenuItem>
                <MenuItem Header="Item 2">
                    <MenuItem Header="Item 2.1"/>
                    <MenuItem Header="Item 2.2"/>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Item 3">
                </MenuItem>
            </ContextMenu>
        </tray:NotifyIcon.Menu>
    </tray:NotifyIcon>

Expected behavior

The popup should be placed right next to the MenuItem. We can achieve that by removing the DropShadowEffect and setting the VerticalOffset and Margin to 0

Screenshots

Image
Image

OS version

Win 11 24H2

.NET version

8.0

WPF-UI NuGet version

latest main branch

Additional context

No response

@alex-lapuka alex-lapuka added the bug Something isn't working label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant