【发布时间】:2018-07-16 17:53:18
【问题描述】:
我想制作一个包含 3 个区域的简单 UI,我希望它们如图所示,每个区域使用大约 33% 的 Window 高度:
我能够做到这个宽度 Grid 和他的 RowDefinitions 但问题是我希望这三个区域根据窗口宽度改变方向,所以我认为使用 StackPanel 而不是 Grid 并将他的“方向”属性更改为“水平”当窗口更大时可能是解决方案。但是现在我面临其他问题,我不知道为每个自动更改的区域设置高度或宽度很热,因为我不能在 Grid.RowDefinitions 中为每个区域使用“0.3*”。
你知道如何实现这个用户界面吗?
谢谢!
编辑:好的,基于这里的评论是我的实际代码:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="500"/>
</VisualState.StateTriggers>
<VisualState.Setters>
// Changes on orientation
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="0.35*"/>
<RowDefinition Height="0.30*"/>
<RowDefinition Height="0.35*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Green">
</Grid>
<Grid Grid.Row="1">
</Grid>
<Grid Grid.Row="2" Background="Blue">
</Grid>
</Grid>
【问题讨论】:
-
当问一个由你的代码引起的问题时,如果你提供人们可以用来重现问题的代码,你会得到更好的答案Read the help
-
@zatamine 感谢您的提示,我已添加。有什么想法吗?
标签: xaml user-interface uwp uwp-xaml stackpanel