Skip to content

Commit 9869da2

Browse files
authored
Merge branch 'main' into dep
2 parents 4c7eeee + e539ae0 commit 9869da2

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

docs/reference/controls/detailed-reference/tray-icon.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,39 @@ You must use a **native menu** with the tray icon, and not the _Avalonia UI_ men
2828
This example defines a simple tray icon menu in the `App.xaml` file :
2929

3030
```xml
31-
<TrayIcon.Icons>
32-
<TrayIcons>
33-
<TrayIcon Icon="/Assets/avalonia-logo.ico"
34-
ToolTipText="Avalonia Tray Icon ToolTip">
35-
<TrayIcon.Menu>
36-
<NativeMenu>
37-
<NativeMenuItem Header="Settings">
38-
<NativeMenu>
39-
<NativeMenuItem Header="Option 1" />
40-
<NativeMenuItem Header="Option 2" />
41-
<NativeMenuItemSeparator />
42-
<NativeMenuItem Header="Option 3" />
43-
</NativeMenu>
44-
</NativeMenuItem>
45-
</NativeMenu>
46-
</TrayIcon.Menu>
47-
</TrayIcon>
48-
</TrayIcons>
49-
</TrayIcon.Icons>
31+
<Application xmlns="https://github.com/avaloniaui"
32+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33+
x:Class="MyApplication.App">
34+
<TrayIcon.Icons>
35+
<TrayIcons>
36+
<TrayIcon Icon="/Assets/avalonia-logo.ico"
37+
ToolTipText="Avalonia Tray Icon ToolTip">
38+
<TrayIcon.Menu>
39+
<NativeMenu>
40+
<NativeMenuItem Header="Settings">
41+
<NativeMenu>
42+
<NativeMenuItem Header="Option 1" />
43+
<NativeMenuItem Header="Option 2" />
44+
<NativeMenuItemSeparator />
45+
<NativeMenuItem Header="Option 3" />
46+
</NativeMenu>
47+
</NativeMenuItem>
48+
</NativeMenu>
49+
</TrayIcon.Menu>
50+
</TrayIcon>
51+
</TrayIcons>
52+
</TrayIcon.Icons>
53+
</Application>
54+
```
55+
56+
Include the `.ico` file in the `.csproj` file using an `AvaloniaResource` item:
57+
58+
```xml
59+
<Project Sdk="Microsoft.NET.Sdk">
60+
<ItemGroup>
61+
<AvaloniaResource Include="Assets/avalonia-logo.ico" />
62+
</ItemGroup>
63+
</Project>
5064
```
5165

5266
<img src={TrayIconScreenshot} alt="" />

0 commit comments

Comments
 (0)