Feature Request: Single application tray window - test.
Hi, i tried to work on some shell experiments for windows to. See it here: https://gitlab.com/bluedxca93/11-shell-gtk/-/tree/main/0-5-beta?ref_type=heads . But im not able to show the system tray. Then i found out that retrobar (that uses managed shell) is the only application that can display the notification area without explorer. Is tehre any method to start a sirt of retrobar with a normal window that only shows the tray area?.
Hi! Yes, you can use ManagedShell to create a notification area without explorer running. Have you seen the quick start that shows how to get started? It is here: https://github.com/cairoshell/ManagedShell/wiki/Getting-Started
Not really, got some sort of progress while looking at retrbar:
<appbar:AppBarWindow x:Class="RetroBar.Taskbar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:RetroBar.Controls"
xmlns:converters="clr-namespace:RetroBar.Converters"
xmlns:utilities="clr-namespace:RetroBar.Utilities"
xmlns:appbar="clr-namespace:ManagedShell.AppBar;assembly=ManagedShell.AppBar"
Title="RetroBar Taskbar" Height="450" Width="800">
<!-- Set the DataContext to your view model, ensuring it exposes NotificationArea -->
<appbar:AppBarWindow.DataContext>
<!-- Replace 'TaskbarViewModel' with your actual view model if needed -->
<utilities:TaskbarViewModel/>
</appbar:AppBarWindow.DataContext>
<Grid>
<!-- Bind the NotifyIconList's NotificationArea property to the view model's NotificationArea -->
<controls:NotifyIconList NotificationArea="{Binding NotificationArea}" />
</Grid>
</appbar:AppBarWindow>
But thats is not what i want. The appbar class conflicts with my gtk shell. It gets tons of window placement errors. Is there a way to not use appbar but normal window decoration?
An AppBar is not needed to use it. Here is a rough basic code example to illustrate.
MainWindow.xaml:
<StackPanel Orientation="Horizontal">
<ItemsControl x:Name="MyTrayUnpinnedItemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Icon}" ToolTip="{Binding Title}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl x:Name="MyTrayPinnedItemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Icon}" ToolTip="{Binding Title}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
MainWindow.xaml.cs:
ShellManager shellManager = new ShellManager();
MyTrayPinnedItemsControl.ItemsSource = shellManager.NotificationArea.PinnedIcons;
MyTrayUnpinnedItemsControl.ItemsSource = shellManager.NotificationArea.UnpinnedIcons;
MainWindow.xaml.txt MainWindow.xaml.cs.txt I am impressed by your help, got a lot of things right already. Ned to fix the main window scaling and the context menu but i can now view what is active in tray..
need now to look how to handle the click events, maybe something like this? ` private void PropertiesNotifyIcon_Click(object sender, RoutedEventArgs e) { if (sender is MenuItem menuItem && menuItem.Tag is NotifyIcon notifyIcon) { // Show properties for this icon // This might involve showing a custom dialog, or calling a method on the NotifyIcon notifyIcon.ShowProperties(); } }
private void CloseNotifyIcon_Click(object sender, RoutedEventArgs e)
{
if (sender is MenuItem menuItem && menuItem.Tag is NotifyIcon notifyIcon)
{
// Close or hide the notify icon
notifyIcon.Close();
}
}
}`
See this section for how to handle each of the mouse events: https://github.com/cairoshell/ManagedShell/wiki/Tray-Service#notification-area-icon-interaction
sadly it does not work, showing up tons of errors.Retrobar works but it provides full panel and i want only the notification area. Tried now wven other approaches it seems that you need a compiler different from mingw to implement it. mingw can not use ths low level approach.. ups, writing from my art uniersity account
Could you provide a copy of your code? I can help figure out what is going on, it should work :)