Skip to content

Conversation

@dotMorten
Copy link
Owner

@dotMorten dotMorten commented Oct 9, 2025

        var m = WindowManager.Get(this);
        m.IsVisibleInTray = true;
        m.TrayIconInvoked += TrayIconClicked;
    
   ///...

    private void TrayIconClicked(object? sender, TrayIconInvokedEventArgs e)
    {
        if (e.Type == TrayIconInvokeType.RightMouseUp)
        {
            var flyout = new MenuFlyout();
            flyout.Items.Add(new MenuFlyoutItem() { Text = "WinUI Context Menus!", IsEnabled = false });
            flyout.Items.Add(new MenuFlyoutItem() { Text = "Try Left clicking", IsEnabled = false });
            flyout.Items.Add(new MenuFlyoutSeparator());
            flyout.Items.Add(new MenuFlyoutItem() { Text = "Exit WinUIEx" });
            ((MenuFlyoutItem)flyout.Items.Last()).Click += (s, e) => this.Close();
            e.Flyout = flyout; // Set a flyout to present. Can be any FlyoutBase kind
        }
        else if (e.Type == TrayIconInvokeType.LeftMouseDown)
        {
            var flyout = new Flyout();
            flyout.SystemBackdrop = new MicaBackdrop();
            StackPanel stackPanel = new StackPanel();
            stackPanel.Children.Add(new TextBlock() { Text = "You can put any content here!", FontWeight = Microsoft.UI.Text.FontWeights.Bold });
            stackPanel.Children.Add(new TextBlock() { Text = "Now try right-clicking the icon" });
            flyout.Content = stackPanel;
            e.Flyout = flyout; 
        }
    }
image image

@dotMorten dotMorten requested a review from Copilot October 9, 2025 00:02
@dotMorten dotMorten self-assigned this Oct 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive support for tray context menus and flyouts to the WinUIEx library. It enables developers to display WinUI 3 flyouts when users interact with the system tray icon through various mouse actions.

Key changes:

  • Refactored tray icon functionality into a separate partial class for better organization
  • Added comprehensive event handling for all tray icon mouse interactions (left/right clicks, double-clicks, mouse up/down)
  • Implemented support for displaying WinUI 3 flyouts anchored to the tray icon location

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/WinUIExSample/MainWindow.xaml.cs Added example implementation showing both MenuFlyout and custom Flyout usage with tray icon events
src/WinUIEx/WindowManager.cs Refactored tray icon message handling to use new ProcessTrayIconEvents method and moved tray functionality to partial class
src/WinUIEx/WindowManager.TrayIcon.cs New partial class containing all tray icon functionality, event handling, and flyout display logic
src/WinUIEx/WinUIEx.csproj Updated package release notes to describe the new tray flyout feature
src/Directory.Build.targets Updated version from 2.8.0 to 2.9.0 and baseline validation version

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dotMorten dotMorten requested a review from Copilot October 9, 2025 00:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@dotMorten dotMorten requested a review from Copilot October 9, 2025 03:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Repository owner deleted a comment from Copilot AI Oct 9, 2025
@dotMorten dotMorten requested a review from Copilot October 9, 2025 03:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dotMorten dotMorten merged commit 3cc14e4 into main Oct 9, 2025
1 check passed
@dotMorten dotMorten deleted the tray_context branch October 9, 2025 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants