I am trying to dynamically scale my UI of my WPF based application, I'd like to use the ratio of the current resolution and my native resolution using something like this:
<Grid.LayoutTransform>
<ScaleTransform CenterX="0" CenterY="0" ScaleX="{Binding FormWidth/NativeREsolution}" ScaleY="{Binding FormWidth/NativeREsolution}"/>
</Grid.LayoutTransform>
The reason why I found scale transform is it scales all the UI elements within the container, including frames and subpages.
is there anyway to do this?
Alternatively is there a better way to dynamically scale an application depending on the size of the window?
WPF is Resolution Independent by nature.
The above XAML will cause the
Gridto stretch to the Window size. No horrendous winforms-like hacks required.Edit:
if you want
Everything(including Font Sizes) to scale within aWindow, just use a Viewbox: