Home > Software design >  Change font size in WPF compatible with Ease of Access functions
Change font size in WPF compatible with Ease of Access functions

Time:02-11

I am working on a simple WPF app that needs to be accessible for people with impaired vision.

I am testing my app with the Windows 10 -> Settings -> Ease of Access -> Display -> Make text Bigger slider setting.

I have some section titles (TextBlock) that I want to have a bigger font than the rest of the labels and text in the window. However, if I use the FontSize attribute to make it bigger it is no longer affected by changes to the system text size. Thus, while all other text that hasn't FontSize set gets bigger, the ones that do remain at their fixed size.

Is there a simple way to make some text relatively bigger than the rest while not setting a specific font size value?

CodePudding user response:

Is there a simple way to make some text relatively bigger than the rest while not setting a specific font size value?

I am afraid there is no support for relative font sizes in WPF but you could try to apply a ScaleTransform:

<TextBlock Text="Bigger">
    <TextBlock.RenderTransform>
        <ScaleTransform ScaleX="1.2" ScaleY="1.2" />
    </TextBlock.RenderTransform>
</TextBlock>

CodePudding user response:

This achieved exactly what I wanted. It is not the prettiest, but it works well. https://github.com/dotnet/wpf/issues/3701

  • Related