c# - 如何使应用程序适应 Windows 8 中的多种分辨率

标签 c# xaml windows-8 grid viewbox

我在 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/

相关文章:

windows-8 - Visual Studio错误: "Cannot activate background task. Background Task activation failed."

c# - EntityFramework 核心单元测试 - SQLite 内存模式与 InMemory 提供程序

c# - 简单的 Add 方法产生过多的 IL 代码

c# - 何时何地使用 By 类的 FindElement 方法

wpf - 如何通过 generic.xaml 中定义的键访问资源

silverlight - 这个绑定(bind)语法有什么问题: {Binding List[Index]}?

c# - 如何防止事件的订阅者相互冲突?

silverlight - 如何将 ValueConverter 应用于基于约定的 Caliburn.Micro 绑定(bind)?

windows-8 - 自定义任务栏悬停按钮的代码?

c# - 如何绑定(bind)到异步图像源