0
votes

I've written an application for Windows 8.1, which works on the full screen (is not scrollable). I tried to use theme resources, in belief, that these are prepared for different phones separately; to my surprise, sizes of fonts on much smaller phone than mine (I own Lumia 1320) are exactly the same, resulting in cut button labels.

The layout is done on Grids, so it will scale up or down to size of screen; a few icons are either SymbolIcons or Paths, so they will scale as well, but how should I choose sizes of fonts? I've read a few documents on MSDN pages, but they doesn't mention how to prepare application for scaling to different screen sizes and resolutions from this perspective.

1

1 Answers

1
votes

Edit:

You can try using this for texts:

IsTextScaleFactorEnabled="True"

Previous answer:

You could use a Viewbox which is a quick solution that scales the entire content inside the element. This would be a XAML approach

<ViewBox>
    <!-- XAML children go here -->
</ViewBox>

Documentation: http://msdn.microsoft.com/en-us/windows/apps/windows.ui.xaml.controls.viewbox

You can also pull the screen resolution from the current window and then add predefined resources accordingly:

// Get your style
Style style = (Style)mainWindow.FindResource("MyStyleResource1"); 
var width = Window.Current.Bounds.Width;
if (width < ...)
    style = (Style)mainWindow.FindResource("MyStyleResourceNarrow");
myXAMLElement.Style = style; 

As most of the elements usually scale easily with their sourrounding containers you will only need that for a couple of textblocks, I guess.