WPF Resize Windows

I support a touch screen application that I am rewriting in .Net. Over the years, the resolution of touch screens has increased significantly. Not only is the resolution higher, but the pixels are also much denser, which makes it difficult to view / control the touch buttons.

Is there a way with WPF to make application windows zoom when resolution / pixel density changes? I would rather not redo these screens every few years.

+3
source share
2 answers

Yes there is.

You can wrap your WPF ViewBox container. Here is an example:

<Window x:Class="TestWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">

    <Viewbox Stretch="Uniform">
        <StackPanel Background="Azure" Height="400" Width="300" Name="stackPanel1" VerticalAlignment="Top">
            <Button Name="testBtn" Width="200" Height="50">
                <TextBlock>Test</TextBlock>
            </Button>
        </StackPanel>
    </Viewbox>

</Window>

Screenshot: enter image description here

.

+5

, WPF 1/96 , ( , 96DPI ).

+1

Source: https://habr.com/ru/post/1705649/


All Articles