Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF: Formatting a label
    primarykey
    data
    text
    <p>I have the following code for an Expander:</p> <pre><code> &lt;Expander Name="CompanyLinks" Header="{StaticResource companyLinksHeader}" FontSize="18" FontFamily="Calibri" FontWeight="Bold"&gt; &lt;StackPanel&gt; &lt;Label Content="{StaticResource companyLinksItemSummary}" FontSize="14" FontFamily="Calibri" FontWeight="Bold"/&gt; &lt;Label Content="{StaticResource companyLinksItemInfo}" FontSize="14" FontFamily="Calibri" FontWeight="Bold"/&gt; &lt;Label Content="{StaticResource companyLinksItemIssues}" FontSize="14" FontFamily="Calibri" FontWeight="Bold"/&gt; &lt;Label Content="{StaticResource companyLinksItemMessages}" FontSize="14" FontFamily="Calibri" FontWeight="Bold"/&gt; &lt;/StackPanel&gt; &lt;/Expander&gt; </code></pre> <p>The StaticResources are defined as follows (in my resource dictionary):</p> <pre><code>&lt;sys:String x:Key="companyLinksHeader"&gt;company&lt;/sys:String&gt; &lt;sys:String x:Key="companyLinksItemSummary"&gt;summary&lt;/sys:String&gt; &lt;sys:String x:Key="companyLinksItemInfo"&gt;info&lt;/sys:String&gt; &lt;sys:String x:Key="companyLinksItemIssues"&gt;issues&lt;/sys:String&gt; &lt;sys:String x:Key="companyLinksItemMessages"&gt;messages&lt;/sys:String&gt; </code></pre> <p>Is there a way to define a dictionary entry (or something else) that will handle the Font styling for the Header and Labels so that I don't have to define the same font over and over (and only change it in one place should I want to change the font)?</p> <p><strong>EDIT</strong></p> <p>I found a solution (thanks to those that posted) and am using the following Style for the StackPanel Label items:</p> <pre><code>&lt;!-- Expander Items text style --&gt; &lt;Style x:Key="expanderItemsTextStyle"&gt; &lt;Setter Property="Label.FontFamily" Value="Trebuchet MS"&gt;&lt;/Setter&gt; &lt;Setter Property="Label.FontWeight" Value="Normal"&gt;&lt;/Setter&gt; &lt;Setter Property="Label.FontSize" Value="14"&gt;&lt;/Setter&gt; &lt;Setter Property="Label.Foreground" Value="Aqua"&gt;&lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>and implementing it like this (applying it to the StackPanel so it affects all Labels):</p> <pre><code>&lt;Expander Name="CompanyLinks" Header="{StaticResource companyLinksHeader}" Style="{StaticResource expanderHeaderTextStyle}"&gt; &lt;StackPanel Style="{StaticResource expanderItemsTextStyle}"&gt; &lt;Label Content="{StaticResource companyLinksItemSummary}"/&gt; &lt;Label Content="{StaticResource companyLinksItemInfo}" /&gt; &lt;Label Content="{StaticResource companyLinksItemIssues}" /&gt; &lt;Label Content="{StaticResource companyLinksItemMessages}" /&gt; &lt;/StackPanel&gt; &lt;/Expander&gt; </code></pre> <p>One thing that does not work though is the Label.Foreground. The foreground color remains black but I can change the font, size or weight via the style. If I move the style into the Label definition though the color works. Is this a bug or is there a different property that will set the font color (foreground) of the StackPanel Labels.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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