Open Jeric-X opened 1 year ago
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.
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" }); }
Then click "Add Item"
Like PopupMenu mode, A new Item was Added
No response
2.0.108
WinUI
Visual Studio 2022
Windows 11
Other
Packaged
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.
Describe the bug
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
TrayIconView.xaml.cs
Then click "Add Item"
Expected behavior
Like PopupMenu mode, A new Item was Added
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