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 7799199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:13:52+00:00 2026-06-02T00:13:52+00:00

All my grids could be small and very big depending on window size but

  • 0

All my grids could be small and very big depending on window size but text inside is looking really small on big grid sizes.

My current idea (but I don’t know how to realize it yet) is to make Binding for all Grid elements to single font and then change the font size by

override void OnRender(DrawingContext dc) {

depending on window size.

The question is: Is this idea sane and is there other methods for it?

  • 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-06-02T00:13:54+00:00Added an answer on June 2, 2026 at 12:13 am

    If you have not set the font on inner elements explicitly, they inherit the parent font. So you can change the font size on one of the parent elements (for example the Window itself or the Grid). This changes the font size on all inner elements that has not specified the font size explicitly.

    However if your font should be of different sizes, the best solution in my opinion is binding the font size of elements to the font size of the parent window, and using a value converter to do a scale on the font size:

    Define a value converter like this:

    using System;
    using System.Windows.Data;
    
    namespace WPFTest
    {
        public class FontSizeConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                if (value == null)
                    return null;
                double windowFontSize = (double)value;
                var scale = System.Convert.ToDouble(parameter);
                return windowFontSize * scale;
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    }
    

    And use it in your xaml:

    <Window x:Class="WPFTest.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:test="clr-namespace:WPFTest"
            Title="Window1" Height="300" Width="300" FontSize="20" x:Name="window1">
        <Window.Resources>
            <test:FontSizeConverter x:Key="fontSizeConverter"/>
        </Window.Resources>
        <Grid>
            <StackPanel Grid.Row="0" Grid.Column="0">
                <TextBlock
                    FontSize="{Binding ElementName=window1, Path=FontSize, Converter={StaticResource ResourceKey=fontSizeConverter}, ConverterParameter=1.5}">
                    Text 1
                </TextBlock>
                <TextBlock FontSize="{Binding ElementName=window1, Path=FontSize, Converter={StaticResource ResourceKey=fontSizeConverter}, ConverterParameter=0.7}">
                    Text 2
                </TextBlock>
                <TextBlock >Text 3</TextBlock>
            </StackPanel>
        </Grid>
    </Window>
    

    ConverterParameter is used as the scale of the element’s font related to the window (specified in ElementName property of the binding).

    In this example font of the first TextBlock is 150% of the window font and font of the second TextBlock is 70% of the window. The third TextBlock follows the font size of the window.

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

Sidebar

Related Questions

All of these bits of text look the same, but I am trying to
I'm trying to calculate all the possible values of a grid size (x by
I need to be able to find all grids for a given form. This
What is the best approach to create a nested grids ? //all ideas will
I'd like to have one interface for all my grid related tasks.The tasks implement
What I need is a grid with all employees data, and a link to
I have a JavaScript based page where a grid displays all the data for
I have a parent grid that contains multiple row definitions, all of which have
i created one grid view application, it's working fine now showing all images in
When you set the opacity on a Grid in WPF, all the child elements

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.