-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
[WinUI3 windowless] Crashes when TaskbarIcon
is the only element in ResourceDictionary
#196
Comments
I had some problems with this library combined with winui3. Can you try to add the Taskbar icon in code and make sure that you save it in a static variable? In my case the garbage collector removed the reference. |
I am currently running into some issues with this as well (winUI3). Can't seem to even make the sample project run. Would you TWiesendanger mind providing a simple setup guide on how you managed to use this plugin in your winUI app? Just the .net version, plugin version and minimal code needed to display a notify/tray icon. Whatever I try seems to lead to different unwanted outcome. |
@TheRealHuzy A sample of this issue: https://github.com/koharubiyori/TrayIconTest. I just simply created a blank winui3 app in Visual Studio and added some code following |
@koharubiyori I can make your sample TrayIconTest work if I add the trayicon in the codebehind and making sure that there is a static variable for it. Soemthing like this: using Microsoft.UI.Xaml;
namespace TrayIconTest
{
public partial class App : Application
{
private TrayIcon? _trayIcon;
public App()
{
this.InitializeComponent();
}
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
_trayIcon = new TrayIcon();
}
}
} and the TrayIcon is something like this: public TrayIcon()
{
var trayIcon = new TaskbarIcon
{
ContextMenuMode = ContextMenuMode.SecondWindow,
IconSource = new BitmapImage(new Uri("ms-appx:///Assets/InventorReset_128.ico")),
ToolTipText = "ToolTip",
Visibility = Visibility.Visible,
NoLeftClickDelay = false
};
var contextMenu = new MenuFlyout
{
AreOpenCloseAnimationsEnabled = false
};
var closeMenuItem = new MenuFlyoutItem
{
Text = "Exit",
};
contextMenu.Items.Add(closeMenuItem);
trayIcon.ContextFlyout = contextMenu;
trayIcon.ForceCreate();
} |
@koharubiyori I've tried your sample and I do not know why would it behave like that. I hope that you can work around that by defining it in code behind like @TWiesendanger defined in his sample. |
@TWiesendanger Thank you very much master Tobias! Your sample works fine. |
@koharubiyori I've tried adding more items and it does seem not to expand to text span initially (on the first click/interaction) but the second interaction and every subsequent one does scale the Flyout size properly. What I've done to fix this is to define Width in the first item that I add to the context menu. You might have to tweak the value to the specific longest menu item you have but it does work.
Here is the result. I've tried dynamically calculating the value with something like this
but the main problem is that Width of Items has no initial value. And events like Opening and Opened do not trigger for some unknown reason to me. |
@TheRealHuzy Thank you so much, this is a good workaround. I found that |
Describe the bug
Based on WinUI - Windowless, the message when exiting:
xxx.exe has exited with code 3221226525 (0xc000041d).
TrayIcon.xaml:
Steps to reproduce the bug
No response
Expected behavior
No response
Screenshots
No response
NuGet package version
2.2.0
Platform
WinUI
IDE
Visual Studio 2022
Windows Version
Windows 11
WindowsAppSDK Version
Other
WindowsAppSDK Type
Unpackaged
Manifest
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: