Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A How to set FontFamily for an entire WPF application in a theme?

Edit: I think you've already rejected this solution, but I am guessing that you only set the property for type Window, which won't have much of an effect. Window controls don't display text except...

posted 2y ago by aresavatar‭  ·  edited 2y ago by aresavatar‭

Answer
#5: Post edited by user avatar aresavatar‭ · 2022-04-15T20:13:04Z (over 2 years ago)
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • These styles are implicit, meaning they will apply to all controls of the specified type, because there's no x:Key specified.
  • If you set an _explicit_ style for a control (meaning one with an x:Key), just make sure that you add the same font-family setter to the explicit style, or create a base style which contains it and base the explicit styles on the base style.
  • **Edit**: I think you've already rejected this solution, but I am guessing that you only set the property for type Window, which won't have much of an effect. Window controls don't display text except in the titlebar, and you can't affect the titlebar display without completely restyling the window.
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • These styles are implicit, meaning they will apply to all controls of the specified type, because there's no x:Key specified.
  • If you set an _explicit_ style for a control (meaning one with an x:Key), just make sure that you add the same font-family setter to the explicit style, or create a base style which contains it and base the explicit styles on the base style.
#4: Post edited by user avatar aresavatar‭ · 2022-04-15T20:07:56Z (over 2 years ago)
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • These styles are implicit, meaning they will apply to all controls of the specified type, because there's no x:Key specified.
  • If set an explicit style for control, just make sure that you add the same setter to it, or create a base style which contains it and base the new styles on the base style.
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • These styles are implicit, meaning they will apply to all controls of the specified type, because there's no x:Key specified.
  • If you set an _explicit_ style for a control (meaning one with an x:Key), just make sure that you add the same font-family setter to the explicit style, or create a base style which contains it and base the explicit styles on the base style.
#3: Post edited by user avatar aresavatar‭ · 2022-04-15T20:06:38Z (over 2 years ago)
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • If set an explicit style for control, just make sure that you add the same setter to it, or create a base style which contains it and base the new styles on the base style.
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • These styles are implicit, meaning they will apply to all controls of the specified type, because there's no x:Key specified.
  • If set an explicit style for control, just make sure that you add the same setter to it, or create a base style which contains it and base the new styles on the base style.
#2: Post edited by user avatar aresavatar‭ · 2022-04-15T20:04:07Z (over 2 years ago)
  • The best suggestion I have is to add implicit styles to the resource dictionary for items you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • If set an explicit style for control, just make sure that you add the same setter to it, or create a base style which contains it and base the new styles on the base style.
  • The best suggestion I have is to add implicit styles to the resource dictionary for the _**control types**_ you want this font set on. For example:
  • <Style TargetType="{x:Type TextBlock}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type TextBox}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • <Style TargetType="{x:Type Window}">
  • <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
  • </Style>
  • (etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)
  • If set an explicit style for control, just make sure that you add the same setter to it, or create a base style which contains it and base the new styles on the base style.
#1: Initial revision by user avatar aresavatar‭ · 2022-04-15T20:03:18Z (over 2 years ago)
The best suggestion I have is to add implicit styles to the resource dictionary for items you want this font set on.  For example:

    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
    </Style>

    <Style TargetType="{x:Type TextBox}">
        <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
    </Style>

    <Style TargetType="{x:Type Window}">
        <Setter Property="TextElement.FontFamily" Value="{StaticResource Tajawal}" />
    </Style>

(etc., set all the common controls here like ComboBox, CheckBox, RadioButton...)

If set an explicit style for control, just make sure that you add the same setter to it, or create a base style which contains it and base the new styles on the base style.