2

我在 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 视图中运行良好,但是当我将应用程序更改为 Snap 视图时,Grid 显示在一个小空间中。

任何人都可以帮忙吗?

4

1 回答 1

1

LayoutUpdated在 UI 元素处注册事件。
并根据 重新计算布局Window.Current.Bounds.Width

于 2013-01-31T10:40:08.260 回答