I want to have my HMI application automatically scale in size when the user changes the size of the application or it is run on different PC with different screen resolution.

Use a ViewBox in the Window XAML code.

When you create a WPF application by default the first container in the window is a Grid. Each container has an opening and closing statement in the XAML file.

For example:

<Window x:Class=”MainWindow”

xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

Title=”MainWindow” Height=”350″ Width=”525″>

<Grid>

…..

</Grid>

</Window>



All of your content will be in the grid.

To create a window with resizable content add a ViewBox to the window and put the grid in the ViewBox.

Example:

<Window x:Class=”MainWindow”

xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

Title=”MainWindow” Height=”350″ Width=”525″>

<Viewbox>

<Grid>

….

</Grid>

</Viewbox>

</Window>



Select the view box and set the stretch property the way you want the application to respond. The options are None, Fill, Uniform and Uniform to Fill. The default is uniform.