我正在学习UWP,并且以下代码不起作用:
<Page
x:Class="LearningUWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LearningUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="500" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="myStackPanel.Background" Value="Red" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<StackPanel x:Name="myStackPanel" Background="Blue" >
<TextBlock Text="myTextBlock" />
</StackPanel>
</Grid>
</Grid>
</Page>
我期望窗口width > 500
时背景变为红色。但是,在扩展它时不起作用。如何解决?
答案 0 :(得分:0)
首先将其移至顶部Grid
。
第二,您可能要为Setter
添加MinWindowWidth="0"