Open symonxdd opened 1 year ago
WinUI uses ContextFlyout
instead ContextMenu
. README contains example for WPF.
Thank for getting back so quickly! Though I still can't get it to work. I'm getting following error message when running:
Cannot find a Resource with the Name/Key
TrayMenu
I'm aware this is probably because I didn't define that resource nowhere. I searched the Internet and found some sample code for TrayMenu
, as well as TrayStatusPopup
. I put it in my App.xaml
like so:
App.xaml
:
<Application
x:Class="WinUITrayTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUITrayTest">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
<MenuFlyout x:Key="TrayMenu">
<MenuFlyoutItem Text="Red" Tag="red" />
<MenuFlyoutItem Text="Green" Tag="green"/>
</MenuFlyout>
<Border x:Key="TrayStatusPopup" Background="White" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" Width="auto" Height="auto">
<StackPanel>
<Button Name="btnSetupTray" Content="Setup" Margin="5" Width="70"></Button>
<Button Name="btnExitTray" Content="Exit" Margin="5" Width="50"></Button>
</StackPanel>
</Border>
</ResourceDictionary>
</Application.Resources>
</Application>
As for the last resource, I didn't define anything, because I just wanted to test it out quickly. So this exception appears when building the code:
Failed to assign to property 'H.NotifyIcon.TaskbarIcon.TrayPopup'
Also, if I can suggest. Wouldn't it be much clearer if in the README it'd be specified that for WinUI 3 apps, the property ContextFlyout
should be used? I could be wrong, but I didn't find it nowhere in the repo description?
Also, I think that it'd be very useful to include some sample code for all three resources: TrayMenu
, TrayStatusPopup
and TrayToolTip
. What do you think?
@symonxdd If you already know how to use the H.NotifyIcon you could add examples or improve README.
I thought to add examples for WinUI3 because I use it.
There are two applications here as examples: https://github.com/HavenDV/H.NotifyIcon/tree/master/src/apps/H.NotifyIcon.Apps.WinUI.Windowless https://github.com/HavenDV/H.NotifyIcon/tree/master/src/apps/H.NotifyIcon.Apps.WinUI But I agree with you that the README needs to be improved.
Describe the bug
The XAML compiler gives following errors when using the template code from the README:
ContextMenu
on elementTaskbarIcon
ContextMenu
was not found in typeTaskbarIcon
Steps to reproduce the bug
Expected behavior
The app is supposed to compile / build fine.
Screenshots
NuGet package version
Microsoft.Windows.SDK.BuildTools
: v10.0.22621.755Microsoft.WindowsAppSDK
: v1.2.230217.4H.NotifyIcon.WinUI
: v2.0.93The
Microsoft.WindowsAppSDK
library needed to updated as instructed in the Error List view when trying to install this repo's libraryH.NotifyIcon.WinUI
Platform
WinUI
IDE
Visual Studio 2022
Windows Version
Windows 11
WindowsAppSDK Version
Other
WindowsAppSDK Type
Packaged
Manifest
I don't know what is meant by this, but I assume the content's of my
app.manifest
? I didn't change it.app.manifest
:Additional context
Here's my full MainWindow XAML -and code-behind code:
MainWindow.xaml
:MainWindow.xaml.cs
: