Auth Infant
Auth Infant

Reputation: 1975

How to scale fonts in UWP XAML app based on resolution scaling using "resource system"

The documentation for FontSize indicates that you can using different font sizes for different scalings using "the resource system." Unfortunately, it does not elaborate on how one would do that or what exactly it means by "the resource system."

I have seen some guidance on this stackoverflow question, but that appears to use converters to solve the problem.

Is there another, better, way to do this using "the resource system?"

Upvotes: 1

Views: 802

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32785

The value type of FontSize is double. so you could make double type resource dictionary.

<Application.Resources>
    <ResourceDictionary>
        <x:Double x:Key="SmallFontSize">20</x:Double>
        <x:Double x:Key="BigFontSize">40</x:Double>
    </ResourceDictionary>
</Application.Resources>

For usage

<TextBlock FontSize="{StaticResource SmallFontSize}" Text="Something"><TextBlock>

For dynamically change a FontSize resource value for UWP. Please refer this reply.

Upvotes: 2

Related Questions