我有一个使用 Mahapps Metro 框架的小型应用程序。我想更改标题栏中的图标,例如连接/断开连接图标。我如何访问内容或动态绑定它?
这是我的 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>
另外:我没有 ImageFile(没有 *.ico),我使用 Mahapps.Resources(xaml 文件)中包含的资源。Afaik 必须以某种方式替换 Rectangle 的内容 - 但是如何?