Yes, with WPF you can scale all the artifacts, including characters. But are you sure you really want it? If you use such application with always maximized window, you will get the following effect: for different screen sizes, you will get the same relative character size, relative to one of the two, pixel width or pixel height of the screen. With not very different aspect ratio specs of different devices, it will give you the look scaled to each physical screen nicely. But, from the other hand, the user will screw up the view way too much trying to resize the window down; however, you can curb it by using minimum size (
MinWidth, MinHeight
properties). This problem will be another flip of the coin.
For comparison, I prepared two XAML samples for your. First will scale all elements to the Window size, but not characters, which I formatted to different sizes, to demonstrate the behavior:
<Window x:Class="Scaling.Ui.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="300" Width="300">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top">One element</TextBlock>
<TextBlock DockPanel.Dock="Top" FontSize="20">Another element</TextBlock>
<TextBlock DockPanel.Dock="Top">Smaller element again</TextBlock>
<TextBlock DockPanel.Dock="Top" FontSize="16">Enter text below:</TextBlock>
<Border BorderBrush="Black" BorderThickness="1">
<TextBox/>
</Border>
</DockPanel>
</Window>
Now, it all will be graphically scaled, with characters, if you add
ViewBox
— this is the key. Try it now:
<Window x:Class="Scaling.Ui.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="300" Width="300">
<Viewbox>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top">One element</TextBlock>
<TextBlock DockPanel.Dock="Top" FontSize="20">Another element</TextBlock>
<TextBlock DockPanel.Dock="Top">Smaller element again</TextBlock>
<TextBlock DockPanel.Dock="Top" FontSize="16">Enter text below:</TextBlock>
<Border BorderBrush="Black" BorderThickness="1">
<TextBox/>
</Border>
</DockPanel>
</Viewbox>
</Window>
The good thing about
ViewBox
is: it is fully agnostic about its content element; graphic and text elements are treated equally, the whole
visual tree of the content is treated as graphics. Well, this is good way to show vector graphics, which can be any
Canvas
element with any other elements nested inside. But it could be anything else.
And you can combine these approaches, because you can show some part of the window under
ViewBox
and some not. Besides, you can change all fonts in response to change of rendered size; it can be done using binding or code behind, or both. I warned you about using careful considerations and taking into account all consequences. You decide.
—SA