Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 606045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:12:44+00:00 2026-05-13T17:12:44+00:00

Scenario: I want to use 3 standard font size for my WPF application :

  • 0

Scenario:

I want to use 3 standard font size for my WPF application : BigFontSize, NormalFontSize, and SmallFontSize. These are double values and they are defined in resource dictionary as (where sys is appropriately defined):

<sys:Double x:Key="BigFontSize">18</sys:Double>
<sys:Double x:Key="NormalFontSize">14</sys:Double>
<sys:Double x:Key="SmallFontSize">12</sys:Double>

This works well. But i have randomly selected 14 as a normal size. What i want is to get a system defined font size for NormalFontSize. (If that’s done, I can use a converter as described here to get BigFontSize and SmallFontSize relative to NormalFontSize)

Clue :

I found from the documentation that default font size is stored in a static property (double) SystemFonts.MessageFontSize. But what should I do to retrieve that value to resource dictionary? (I know Binding or DynamicResource cannot be applied. But hey, this is a static value, so how can I apply StaticResource or x:Static or whatever?)

I have tried

<sys:Double x:Key="XXXFontSize">
    <StaticResource ResourceKey="SystemFonts.MessageFontSize" />
</sys:Double>

and

<sys:Double x:Key="XXXFontSize">
    <x:Static ResourceKey="SystemFonts.MessageFontSize" />
</sys:Double>

Both of which doesn’t seem to work (as expected). I get an error saying Cannot add content to object of type 'System.Double'.

Note:

  • I don’t want to do this from code, e.g from App(). (Is it possible to have a code-behind for ResourceDictionary?)
  • I don’t want to encapsulate this in generalized style from which other styles can be derived (using BasedOn) because I have several Resource Dictionaries, and it’ll not be possible to use DynamicResource with BasedOn
    That is, I cannot use

    <Style x:Key="BigFont" TargetType="{x:Type Control}"}>
        <Setter Property="Control.FontSize" 
                Value="{Binding Source={x:Static SystemFonts.MessageFontSize},
                                Converter={ . . . }" />
    </Style>
    

    Because, if I have a style in other ResourceDictionary, say HeaderTextBlockStyle, then I would have to use BasedOn={DynamicResource BigFont} which is not possible (I think)

Any help would be greatly appreciated.
Thank you.

TAGS : WPF SystemFonts.MessageFontSize ResourceDictionary FontSize BasedOn DynamicResource

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:12:44+00:00Added an answer on May 13, 2026 at 5:12 pm

    I’ve done like this…

    public partial class GlobalResources : ResourceDictionary
    {
        public GlobalResources()
        {
            this.Add("GiantFontSize", SystemFonts.MessageFontSize * 2.5);
            this.Add("BigFontSize", SystemFonts.MessageFontSize * 1.5);
            this.Add("MediumFontSize", SystemFonts.MessageFontSize * 1.25);
            this.Add("NormalFontSize", SystemFonts.MessageFontSize);
            this.Add("SmallFontSize", SystemFonts.MessageFontSize * 0.85);
        }
    }
    

    … and it’s working like like a miracle!!! I can use these resources in the same (partial) resource dictionary or from other resource dictionaries like this…

    <Style ...>
        <Setter Property="FontSize"
                Value="{DynamicResource MediumFontSize}" />
    
        ...
    
    </Style>
    

    I don’t know if it is a “good practice” or not (please comment on this), I only know that it works..!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario I have a windows forms application. I want to use two different WCF
I want to use System.Numerics.Complex in an unmanaged PInvoke scenario. Using ILSpy, I noticed
I want to present you my windows forms application scenario: I want to create
Goal: I want to use jsf`s i18n Scenario: creating resource bundle (utf-8) file info:
I just came across a curious scenario where I want to use removeEventListener() within
I want to use my django web application with RESTful services. I already created
Here's a standard scenario: if(string.IsNullOrEmpty(Configuration.AppSettings[foobar])) throw new SomeStandardException(Application not configured correctly, bozo.); The problem
I have a scenario and want to use multiple ReceiveAndSendReply activities running in parallel
Scenario I want to use Glyphs on WP7 to create a line of text
I have a scenario where I want to use a data join to append

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.