VisualStateTrigger not updating
本文关键字:updating not VisualStateTrigger | 更新日期: 2023-09-27 18:17:57
我正在制作一个通用Windows应用程序。我使用Splitview
为我的菜单,如果我调整我的窗口大小,我使用视觉状态触发器来调整布局。但它似乎不起作用。
我在微软网站上看了一个讲座。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
DataContext="{StaticResource MainPageViewModel}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="AdaptiveStates">
<VisualState x:Name="Min720State">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SplitViewMenu.DisplayMode" Value="CompactInline" />
<Setter Target="SplitViewMenu.IsPaneOpen" Value="True" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Min320State">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="320" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SplitViewMenu.DisplayMode" Value="CompactOverlay" />
<Setter Target="SplitViewMenu.IsPaneOpen" Value="False" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="DefaultState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SplitViewMenu.DisplayMode" Value="Overlay" />
<Setter Target="SplitViewMenu.IsPaneOpen" Value="false" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Button x:Name="NavButton" Style="{StaticResource BtnNav}" Content="" Click="NavButton_Click" />
<TextBlock Text="SoundCloud Plus" Style="{StaticResource AppTitle}" />
</Grid>
<SplitView x:Name="SplitViewMenu" Grid.Row="1" CompactPaneLength="48" IsPaneOpen="True" DisplayMode="CompactInline">
<SplitView.Pane>
<ScrollViewer>
<StackPanel>
<Button Style="{StaticResource ButtonsInMenu}" x:Name="AccountButton" Click="AccountButton_Click">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Width="36" Height="36" Source="/Assets/Square44x44Logo.targetsize-24_altform-unplated.png"/>
<TextBlock Style="{StaticResource TextInMenu}" Grid.Column="1" Text="Connect with SoundCloud" />
</Grid>
</Button>
<Button Style="{StaticResource ButtonsInMenu}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="/Assets/Square44x44Logo.targetsize-24_altform-unplated.png"/>
<TextBlock Style="{StaticResource TextInMenu}" Grid.Column="1" Text="Recent" />
</Grid>
</Button>
<Button Style="{StaticResource ButtonsInMenu}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="/Assets/Square44x44Logo.targetsize-24_altform-unplated.png"/>
<TextBlock Style="{StaticResource TextInMenu}" Grid.Column="1" Text="Artists" />
</Grid>
</Button>
</StackPanel>
</ScrollViewer>
</SplitView.Pane>
<SplitView.Content>
<Frame x:Name="MyFrame"></Frame>
</SplitView.Content>
</SplitView>
</Grid>
尝试删除splitview中的IsPaneOpen="True"