我在 xaml 中有下面的布局代码
<Grid>
<StackPanel x:Name="TestStackPanel" Grid.Row="2" Orientation="Horizontal">
<ScrollViewer x:Name="TestScrollViewer" Height="300" VerticalScrollBarVisibility="Auto">
<GridView x:Name="TestGridView"
Width="940"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
ItemTemplate="{StaticResource TestTemplate}"
ItemsPanel="{StaticResource TestItemPanelTemplate}"
ItemContainerStyle="{StaticResource TestItemStyle}"
SelectionMode="None"
HorizontalAlignment="Left"/>
</ScrollViewer>
<Button x:Name="TestButton" Content="ClickMe" VerticalAlignment="Bottom" Margin="10,5,0,0" Click="TestButton_Click"/>
</StackPanel>
</Grid>
这在 1366*768 分辨率下显示良好,但如果我将分辨率更改为 2560*1400,它无法按预期显示,我知道这是肯定的,但是如何将布局调整为不同的分辨率?我尝试添加一个 ViewBox 来封装 Grid,它在 FullScreenLandScape View 中运行良好,但是当我将应用程序更改为 Snap View 时,Grid 显示在一个小空间中。
有人可以帮忙吗?
最佳答案
在 UI 元素上注册到 LayoutUpdated
事件。
并根据Window.Current.Bounds.Width
重新计算布局。
关于c# - 如何使应用程序适应 Windows 8 中的多种分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14577267/