檢測螢幕解析度變化後自動調整viewbox內部容器大小 - 動態適配螢幕解析度
<Window SizeChanged="Window_SizeChanged">
<Viewbox x:Name="mainViewbox"
Stretch="Uniform" StretchDirection="Both" >
<grid x:Name="mainContainer" Margin="0" >grid 的寬和高和螢幕解析度保持一致
</grid>
</Viewbox>
</Window>
後臺
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
//mainViewbox.widmainViewbox
mainContainer.Width = e.NewSize.Width;
mainContainer.Height = e.NewSize.Height;
}