Search code examples
c#windows-runtimewindows-phone-8.1windows-store-appswinrt-xaml

Windows Phone 8.1 Different text size for different screen dimension


I am developing a windows runtime app for windows phone, i need to scale the text based on the screen dimension.

for handle the image scaling i have used the 3 folder(scale-100, scale-140 and scale-240)

In the app I have different style for different kind of text(title, subtitle...)

is there any way to apply different style based on the screen size?


Solution

  • Following solution is for Windows (Phone) RT, not for WP Silverlight.

    The resource system of Windows RT is much more powerful than a lot of people know. You're not only able to use scaling for images, the same works for resource (.resw) files, even a combination of language/scaling is possible. Simply use the correct naming conventions: e.g. Resources.scale-140.resw.

    And then you're able to put about every single attached/dependency property in your resource file, leveraging the resource system based on x:Uid.

    <Grid x:Uid="MainGrid">
        <TextBlock x:Uid="MyTextBlock" />
    </Grid>
    

    Resource file

    You can run a few of the different emulator sizes to test if everything works as desired.