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

[WinUI] Menu items changes in c# code doesn't change contextmenu with SecondWindow mode #97

Open
Jeric-X opened this issue Jun 8, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Jeric-X
Copy link

Jeric-X commented Jun 8, 2023

Describe the bug

MenuFlyoutName.Items.Add(new MenuFlyoutItem() { Text = "new added" });

changing MenuFlyou.Items doesn't change context menu
If set ContextMenuMode=PopupMenu or ActiveWindow, context menu does change.

Steps to reproduce the bug

change H.NotifyIcon.Apps.WinUI project
TrayIconView.xaml

    <tb:TaskbarIcon
        x:Name="TrayIcon"
        x:FieldModifier="public"
        IconSource="ms-appx:///Assets/Red.ico"
        ToolTipText="ToolTip"
        LeftClickCommand="{x:Bind ShowHideWindowCommand}"
        NoLeftClickDelay="True"
        ContextMenuMode="SecondWindow"
        >
        <tb:TaskbarIcon.ContextFlyout>


<!--  Changes here  -->
            <MenuFlyout AreOpenCloseAnimationsEnabled="False" x:Name="Menu">
                <MenuFlyoutItem Command="{x:Bind AddCommand}" Text="Add Item" />
<!--  Changes here  -->


                 <MenuFlyoutItem Command="{x:Bind ShowHideWindowCommand}" Text="Show/Hide Window" />
                <MenuFlyoutSeparator />
                <MenuFlyoutItem Command="{x:Bind ExitApplicationCommand}" Text="Exit" />
            </MenuFlyout>
        </tb:TaskbarIcon.ContextFlyout>
    </tb:TaskbarIcon>

TrayIconView.xaml.cs

    [RelayCommand]
    public void Add()
    {
        Menu.Items.Add(new MenuFlyoutItem() { Text = "new added" });
    }

yeycuq1l ebw
Then click "Add Item"

Expected behavior

Like PopupMenu mode, A new Item was Added
vrjuvui4 y5p

Screenshots

No response

NuGet package version

2.0.108

Platform

WinUI

IDE

Visual Studio 2022

Windows Version

Windows 11

WindowsAppSDK Version

Other

WindowsAppSDK Type

Packaged

Manifest

No response

Additional context

No response

@Jeric-X Jeric-X added the bug Something isn't working label Jun 8, 2023
@Jeric-X
Copy link
Author

Jeric-X commented Jun 9, 2023

The reason is that the real working MenuFlyout(and it's Items) is the second transparent window's property. Items in xaml is just for preparation.

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