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

  • Home
  • SEARCH
  • 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 4043884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:11:02+00:00 2026-05-20T13:11:02+00:00

My question is very similar to Wpf custom control template – relative font size

  • 0

My question is very similar to Wpf custom control template – relative font size … but I’m trying to set the font size in one resource relative to that of another resource. I implemented the solution posted by Thomas, but I can’t figure out how to make the Relative source point to another resource.

            <my:MathConverter x:Key="MathConverter" />

            <Style x:Key="propertyText">
                <Setter Property="Control.Foreground" Value="Gray" />
                <Setter Property="Control.FontSize" Value="12" />
                <Setter Property="Control.Padding" Value="10,2,2,2" />
            </Style>

            <Style x:Key="headerText">
                <!-- I want this to be the same as propertyText +2 -->
                <Setter Property="Control.FontSize" Value="FontSize="{Binding
                 RelativeSource={RelativeSource AncestorType={x:Type Window}},
                 Path=FontSize,
                 Converter={StaticResource MathConverter},
                 ConverterParameter=2}" />
            </Style>

Here is the line I’m having trouble with. I want it to point to propertyText instead:

                 RelativeSource={RelativeSource AncestorType={x:Type Window}},

For completeness, here is the code for the converter :

public class MathConverter : IValueConverter
{
    public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
    {
        return (double)value + double.Parse( parameter.ToString() );
    }

    public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
    {
        return null;
    }
}

Based on Markus Hütter’s reply. Here is the XAML for the solution:

           <system:Double x:Key="baseFontSize">12</system:Double>
            <my:MathConverter x:Key="MathConverter" />
            <Style x:Key="propertyText">
                <Setter Property="Control.Foreground" Value="Gray" />
                <Setter Property="Control.FontSize" Value="{StaticResource ResourceKey=baseFontSize}" />
                <Setter Property="Control.Padding" Value="10,2,2,2" />
            </Style>

            <Style x:Key="headerText">
                <!-- I want this to be the same as propertyText +2 -->
               <Setter Property="Control.FontSize" 
                       Value="{Binding Source={StaticResource ResourceKey=baseFontSize},
                       Converter={StaticResource MathConverter},
                       ConverterParameter=2}" />
            </Style>
  • 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-20T13:11:02+00:00Added an answer on May 20, 2026 at 1:11 pm

    easiest would be:

    create a resource

    <system:Double x:Key="propertyTextFontSize">12</system:Double>
    

    and use a StaticReference in the setters both pointing to this resource but the second one with the binding and converter.

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

Sidebar

Related Questions

Note: There's a very similar question , but it's WPF-specific; this one is not.
My question popped up a very similar question, this one . But the accepted
My question is very similar to this one How to reference a custom field
this question is very similar to this one but my case is a bit
This question is very similar to one I recently asked: Python threading- returning control
I have a question very similar to this one but the answer does not
I asked a very similar question here but since it is such a fundamental
I've seen a very similar question was posted but his solution didn't help. I'm
I know there is a very similar question here but I was hoping to
My question is very similar to the question posted here on stackoverflow but the

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.