Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork893
fix: make notifyicon contextmenu display#1534
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
use x:Name=MainWindow is better, but i want less code. |
TooltipText="WPF UI Gallery"> | ||
<tray:NotifyIcon.Menu> | ||
<ContextMenuItemsSource="{Binding ViewModel.TrayMenuItems, Mode=OneWay}" /> | ||
<ContextMenuDataContext="{Binding DataContext, Source={x:Reference NavigationView}}"ItemsSource="{Binding ViewModel.TrayMenuItems, Mode=OneWay}" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ithinkx:Reference
is discouraged, but I'm only not sure after readinghttps://learn.microsoft.com/en-us/dotnet/desktop/xaml-services/xreference-markup-extension#xreference-and-wpf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
<tray:NotifyIconFocusOnLeftClick="True"MenuOnRightClick="True"><tray:NotifyIcon.Resources><DiscreteObjectKeyFrame x:Key="proxy"Value="{Binding}"/></tray:NotifyIcon.Resources><tray:NotifyIcon.Menu><ContextMenu DataContext="{Binding Source={StaticResource proxy},Path=Value}"><ui:MenuItem Name="OpenSettings"Command="{Binding OpenSettingsCommand}"CommandParameter="123"Header="{x:Static str:Resources.AppSetting}"/><ui:MenuItem Name="Exit" Command="{Binding ExitAppCommand}" Header="{x:Static str:Resources.AppExit}"/></ContextMenu></tray:NotifyIcon.Menu></tray:NotifyIcon>
ok,i have plan b
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: N/A
NotifyIcon's ContextMenu not display
What is the new behavior?
Other information
The context menu isn't part of the same visual tree and therefore doesn't have the same DataContext.
I have provided a tip here to solve this problem.