File tree 1 file changed +33
-19
lines changed
docs/reference/controls/detailed-reference
1 file changed +33
-19
lines changed Original file line number Diff line number Diff line change @@ -28,25 +28,39 @@ You must use a **native menu** with the tray icon, and not the _Avalonia UI_ men
28
28
This example defines a simple tray icon menu in the ` App.xaml ` file :
29
29
30
30
``` 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 >
50
64
```
51
65
52
66
<img src ={TrayIconScreenshot} alt =" " />
You can’t perform that action at this time.
0 commit comments