Fix Systray binding errors

This commit is contained in:
Théo Marchal 2021-08-14 12:03:09 +02:00
parent c95094a003
commit 4f97443d09
2 changed files with 40 additions and 45 deletions

View File

@ -1,49 +1,48 @@
<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:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:local="clr-namespace:unison">
<tb:TaskbarIcon x:Name="SystrayTaskbar" xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
IconSource="/images/unison.ico" ToolTipText="{Binding GetAppText}" DoubleClickCommand="{Binding ShowWindowCommand}" x:Key="SystrayTaskbar">
<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem IsEnabled="False">
<MenuItem.Icon>
<Image Source="/images/unison.ico" Width="16" Height="16"/>
</MenuItem.Icon>
<MenuItem.Header>
<TextBlock Text="{Binding GetAppText}" />
</MenuItem.Header>
</MenuItem>
<Separator />
<MenuItem Header="Show window" Command="{Binding ShowWindowCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="▶️" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Name="test_snapcast_item" Header="{Binding SnapcastText}" Command="{Binding Snapcast}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="🔊" />
</MenuItem.Icon>
</MenuItem>
<!--<MenuItem Header="Shuffle" Command="{Binding Shuffle}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="🔀" />
</MenuItem.Icon>
</MenuItem>-->
<MenuItem Header="Settings" Command="{Binding Settings}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="🛠️" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Exit" Command="{Binding ExitApplicationCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="❌" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
<ContextMenu x:Shared="false" x:Key="SystrayMenu">
<MenuItem IsEnabled="False">
<MenuItem.Icon>
<Image Source="/images/unison.ico" Width="16" Height="16"/>
</MenuItem.Icon>
<MenuItem.Header>
<TextBlock Text="{Binding GetAppText}" />
</MenuItem.Header>
</MenuItem>
<Separator />
<MenuItem Header="Show window" Command="{Binding ShowWindowCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="▶️" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Name="test_snapcast_item" Header="{Binding SnapcastText}" Command="{Binding Snapcast}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="🔊" />
</MenuItem.Icon>
</MenuItem>
<!--<MenuItem Header="Shuffle" Command="{Binding Shuffle}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="🔀" />
</MenuItem.Icon>
</MenuItem>-->
<MenuItem Header="Settings" Command="{Binding Settings}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="🛠️" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Exit" Command="{Binding ExitApplicationCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" emoji:Image.Source="❌" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
<tb:TaskbarIcon x:Key="SystrayTaskbar" IconSource="/images/unison.ico" ToolTipText="{Binding GetAppText}" DoubleClickCommand="{Binding ShowWindowCommand}" ContextMenu="{StaticResource SystrayMenu}">
<tb:TaskbarIcon.DataContext>
<local:SystrayViewModel />
</tb:TaskbarIcon.DataContext>

View File

@ -8,10 +8,6 @@ namespace unison
{
public class SystrayViewModel : INotifyPropertyChanged
{
public SystrayViewModel()
{
}
public string GetAppText => "unison v" + Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
public ICommand ShowWindowCommand => new DelegateCommand