-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotifyIconResources.xaml
21 lines (18 loc) · 1.21 KB
/
NotifyIconResources.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:D2RoshTimer">
<!--The "shared" directive is needed if we reopen the sample window a few times - WPF will otherwise reuse the same context menu (which is a resource) again (which will have its DataContext set to the old TaskbarIcon) -->
<ContextMenu x:Shared="false" x:Key="SysTrayMenu">
<MenuItem Header="Change Keybind" Command="{Binding ShowWindowCommand}"/>
<Separator/>
<MenuItem Header="Exit" Command="{Binding ExitApplicationCommand}"/>
</ContextMenu>
<!-- the application's NotifyIcon - started from App.xaml.cs. Declares its own view model. -->
<tb:TaskbarIcon x:Key="NotifyIcon" IconSource="/Resources/D2Roshtimer.ico" ToolTipText="Double-click for window, right-click for menu" DoubleClickCommand="{Binding ShowWindowCommand}" ContextMenu="{StaticResource SysTrayMenu}">
<!-- self-assign a data context (could also be done programmatically) -->
<tb:TaskbarIcon.DataContext>
<local:NotifyIconViewModel/>
</tb:TaskbarIcon.DataContext>
</tb:TaskbarIcon>
</ResourceDictionary>