Search code examples
c#wpfresize

Resize WPF Window and contents depening on screen resolution


I have a WPF app with multiple controls on each window, some overlayed etc, what i need is a way of getting the app to resize itself automatically depending on the screen resolution.

Any ideas ?


Solution

  • Just simply make a binding like that:

    <Window x:Class="YourApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="YourApplication" 
        Height="{Binding SystemParameters.PrimaryScreenHeight}" 
        Width="{Binding SystemParameters.PrimaryScreenWidth}">