I've made a little WPF test-application with buttons in different units. Now I run this on a Screen with 96dpi and another with 226dpi.
What I expect is that the button without unit and the button with px unit would get smaller than the other buttons on the 226dpi display - but they keep all the same size.
How do I force the "pixel"-Buttons to use real pixels? Independent of the dpi-resolution or if the user set the scaling to 200%.
In my real application I want the Menüs and Trees and so on to be dpiaware, but in the middle I have some sort of graphics in a usercontrol and I want this usercontrol to use real pixels.
Here is the democode:
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0" Grid.Column="0" Content="96 x 48" Width="96" Height="48" />
<Button Grid.Row="1" Grid.Column="0" Content="96px x 48px" Width="96px" Height="48px" />
<Button Grid.Row="2" Grid.Column="0" Content="1.0in x 0.5in" Width="1.0in" Height="0.5in" />
<Button Grid.Row="3" Grid.Column="0" Content="2.54cm x 1.27cm" Width="2.54cm" Height="1.27cm" />
</Grid>
</Window>