Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I Change the FontFamily on a ContentPresenter?
    text
    copied!<p>I have a custom template for an expander that is close to the code below. I had to change some of the code to take out custom classes, brushes, etc..</p> <pre><code>&lt;Style TargetType="{x:Type Expander}"&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch" /&gt; &lt;Setter Property="VerticalContentAlignment" Value="Top" /&gt; &lt;Setter Property="BorderBrush" Value="Transparent" /&gt; &lt;Setter Property="FontFamily" Value="Tahoma" /&gt; &lt;Setter Property="FontSize" Value="12" /&gt; &lt;Setter Property="Foreground" Value="Black" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;Setter Property="Margin" Value="2,0,0,0" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Expander}"&gt; &lt;Border x:Name="Border" SnapsToDevicePixels="true" Background="White" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="0,0,0,10" Padding="0" CornerRadius="8"&gt; &lt;DockPanel&gt; &lt;Border x:Name="HeaderSite" Background="Blue" CornerRadius="8" Height="32" DockPanel.Dock="Top"&gt; &lt;DockPanel&gt; &lt;ToggleButton Foreground="White" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0" MinHeight="0" MinWidth="0" Padding="6,2,6,2" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Left"&gt; &lt;/ToggleButton&gt; &lt;ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" ContentSource="Header" VerticalAlignment="Center" RecognizesAccessKey="True" /&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;Border x:Name="InnerBorder" Margin="0" &gt; &lt;ContentPresenter Focusable="false" Visibility="Collapsed" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" DockPanel.Dock="Bottom" /&gt; &lt;/Border&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsExpanded" Value="true"&gt; &lt;Setter Property="Margin" TargetName="InnerBorder" Value="5" /&gt; &lt;Setter Property="Visibility" TargetName="ExpandSite" Value="Visible" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>As you can see there are two ContentPresenters. I would like the first one to use Tahoma Bold as the font instead of the default Tahoma. How can I do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload