Author Posts

March 15, 2018 at 3:51 pm

I have a xaml form with some text in a TextBlock, what is the best way to scale the text depending on the DPI and zoom setting people have on their monitors so the text will still be readable at 1600 x 900 and 800 x 600 but I can't find an AutoScaleMode to make the form dpi and zoom aware

TextBlock HorizontalAlignment="Stretch" Margin="12,6,12,12" FontFamily="Arial" FontSize="32"
Name="TextDisplay" VerticalAlignment="Stretch" Background="LightGray"
Foreground="Black" TextAlignment="Center" FontStretch="Expanded">
TextBlock

March 15, 2018 at 7:02 pm

I don't have the answer for that one as maybe I just haven't run into that yet. If you find an answer, I'd be interested to hear it.

While this forum is great for PowerShell, your question is more specifically about WPF applications. In your case, you are just using PowerShell to create it. If you search around a wpf example on how to cover the taskbar even if it is pinned, you may be more likely to find an answer. In some cases, you may need to adapt the answer from a C# example.

March 16, 2018 at 9:40 am

Hi Will, I have come up with one solution, there will be better 🙂 I found if I wrapped the Textblock in a viewbox and another grid the text autoscales to resolution. The strange this is that on lower resolutions i.e. 800 x 600 the text is smaller than on higher resolutions. But hey I think I can live with that 🙂

Viewbox Stretch="Fill" StretchDirection="Both" Margin="200" VerticalAlignment="Top" HorizontalAlignment="Left"
Grid

TextBlock HorizontalAlignment="Stretch" Margin="12,6,12,12" FontFamily="Arial" TextWrapping = "Wrap"
Name="TextDisplay" VerticalAlignment="Stretch" Background="LightGray"
Foreground="Black" TextAlignment="Center" FontStretch="Expanded"
TextBlock

Grid
Viewbox

March 16, 2018 at 9:44 am

Also to cover the taskbar just add

WindowState="Maximized"
WindowStyle="None"

Topmost="True"