I have a small application, using the Mahapps Metro Framework. I would like to change the icon in the title bar like connect/disconnect icon. How can i access the content or bind it dynamically?
This is my XAML:
<Controls:MetroWindow x:Class="NFCAgent.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
Title="NFC-Agent"
Height="55"
Width="250"
ResizeMode="NoResize"
GlowBrush="{DynamicResource AccentColorBrush}"
WindowStartupLocation="Manual"
Topmost="True"
ShowIconOnTitleBar="True">
<Controls:MetroWindow.LeftWindowCommands>
<Controls:WindowCommands>
<Button IsEnabled="False" >
<StackPanel Orientation="Horizontal">
<Rectangle x:Name="headerLogo" Width="20" Height="20"
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill"
Visual="{DynamicResource appbar_cupcake}" />
</Rectangle.OpacityMask>
</Rectangle>
</StackPanel>
</Button>
</Controls:WindowCommands>
</Controls:MetroWindow.LeftWindowCommands>
<Grid>
<StackPanel Orientation="Horizontal">
<Rectangle Width="25" Height="25" Margin="4 0">
<Rectangle.Fill>
<VisualBrush Visual="{DynamicRessource appbar_add}" />
</Rectangle.Fill>
</Rectangle>
<TextBlock x:Name="txtStatus" Text="Statusinfo" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</Grid>
Addition: I have no ImageFile (no *.ico), i use the Resources that are included in Mahapps.Resources (xaml-Files). Afaik the content of the Rectangle must be replaced in some way - but how?