Reputation: 18
I am beginning to learn WPF and I choose MahApps.Metro for styling as it looked cool. The problem I am facing is that after changing the font of MetroWindow the WindowCommandButton's font is updated accordingly but the font of the buttons is not getting updated. I continue to see tiny texted buttons.
My XAML looks like this as of now
<MahApps:MetroWindow
x:Class="MetroSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MetroSample"
xmlns:MahApps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
Title="Metro Sample"
Height="350" Width="525"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}" FontFamily="Lucida Sans Unicode" FontSize="14.667">
<MahApps:MetroWindow.RightWindowCommands>
<MahApps:WindowCommands>
<Button x:Name="btnReqLogs">
<StackPanel Orientation="Horizontal">
<Rectangle Width="20" Height="20" Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_book_list}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="4 0 0 0" VerticalAlignment="Center" Text="Request Logs" />
</StackPanel>
</Button>
<Button x:Name="btnSettings">
<StackPanel Orientation="Horizontal">
<Rectangle Width="20" Height="20" Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_settings}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="4 0 0 0" VerticalAlignment="Center" Text="Settings" />
</StackPanel>
</Button>
</MahApps:WindowCommands>
</MahApps:MetroWindow.RightWindowCommands>
<DockPanel LastChildFill="True">
<DockPanel Height="50" DockPanel.Dock="Top" LastChildFill="False">
<Button DockPanel.Dock="Left"
MahApps:ButtonHelper.PreserveTextCase="True" Background="Transparent"
Content="First Button" Padding="10,0" Width="150" Margin="0,0,2,0"/>
<Button DockPanel.Dock="Left"
MahApps:ButtonHelper.PreserveTextCase="True" Background="Transparent"
Content="Second Button" Padding="10,0" Width="150" Margin="0,0,2,0"/>
<Button DockPanel.Dock="Right"
MahApps:ButtonHelper.PreserveTextCase="True" Background="Transparent"
Content="Logout" Padding="10,0" Width="150" Margin="0,0,2,0"/>
</DockPanel>
<StackPanel>
</StackPanel>
</DockPanel>
Upvotes: 0
Views: 1098
Reputation: 14487
Button.FontFamily
doesn't inherit from parent control. It is defined in the base style :
<Setter Property="FontFamily" Value="{DynamicResource DefaultFont}" />
You can override that with the following :
<Style BasedOn="{StaticResource MetroButton}" TargetType="Button">
<Setter Property="FontFamily" Value="Lucida Sans Unicode" />
</Style>
Or, you can override that globally for every style that also happens to use it via (but, don't do this) :
<FontFamily x:Key="DefaultFont">Lucida Sans Unicode</FontFamily>
Upvotes: 1