0
我正在玩耍/學習UWP的視覺狀態管理器。當我點擊應用程序的最大化/最小化按鈕時,我有一段代碼不會響應觸發器/設置器。它響應良好,如果我手動調整框的大小雖然。視覺狀態管理器未響應最大化/最小化按鈕
我有第二塊代碼,當我點擊最大化/最小化按鈕時,它會觸發觸發器/設置器。
這兩個代碼看起來都非常相似,但似乎我錯過了一些東西。預先感謝您的協助
這裏是沒有響應最大化碼/最小化按鈕:
<Grid Name="MyGrid" Background="White">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Groups">
<VisualState x:Name="WindowsPhone">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MySplitView.DisplayMode" Value="Inline"/>
<Setter Target="HamburgerButton.Width" Value="100"/>
<Setter Target="MyGrid.Background" Value="LightBlue"/>
<Setter Target="AutoSuggestBox.Visibility" Value="Compact"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="WindowsTablet">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MySplitView.DisplayMode" Value="Overlay"/>
<Setter Target="AutoSuggestBox.Visibility" Value="Visible"/>
<Setter Target="MyGrid.Background" Value="HotPink"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Desktop">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="800"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MyGrid.Background" Value="Orange"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RelativePanel>
<Button Name="HamburgerButton"
Width="50"
Height="50"
Click="HamburgerButton_Click"
FontFamily="Segoe MDL2 Assets"
Content=""
RelativePanel.AlignLeftWithPanel="True"/>
<AutoSuggestBox Name="AutoSuggestBox"
QueryIcon="Find"
PlaceholderText="Search"
Width="200"
RelativePanel.AlignRightWithPanel="True"
Margin="0,10,0,0"/>
</RelativePanel>
<SplitView Grid.Row="1"
Name="MySplitView"
IsPaneOpen="False"
CompactPaneLength="50"
OpenPaneLength="200"
DisplayMode="CompactOverlay">
<SplitView.Pane>
<ListBox Name="MylistBox"
SelectionMode="Single"
SelectionChanged="MylistBox_SelectionChanged">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Name="FirstIcon"
FontFamily="Segoe MDL2 Assets"
FontSize="30"
Text=""/>
<TextBlock Name="TextTextBlock"
FontSize="20"
Text="Hello"
FontWeight="Bold"
Margin="20,0,0,0"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Name="SecondIcon"
FontFamily="Segoe MDL2 Assets"
FontSize="30"
Text=""/>
<TextBlock Name="SeconTextBlock"
FontFamily="20"
Text="Hello Again"
FontWeight="Bold"
Margin="20,0,0,0"/>
</StackPanel>
</ListBoxItem>
</ListBox>
</SplitView.Pane>
</SplitView>
</Grid>
這是正常工作的代碼:
<Grid Name="ColorGrid" Background="Pink">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="VisualStatePhone">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColorGrid.Background" Value="Red"/>
<Setter Target="MessageTextBlock.FontSize" Value="18"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateTablet">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColorGrid.Background" Value="Yellow"/>
<Setter Target="MessageTextBlock.FontSize" Value="40"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateDesktop">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="800"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColorGrid.Background" Value="Blue"/>
<Setter Target="MessageTextBlock.FontSize" Value="60"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBlock Name="MessageTextBlock" Text="Hello I am forgetting something"/>
</Grid>
我能夠重現這在一個空白的項目上14393.關於這個奇怪的是,這似乎只在調試會話發生。如果您運行時未經調試,或從開始啓動,則一切正常。 – BoltClock
@BoltClock嗯。奇怪的確如此。我按照您提到的方式進行測試,無需調試或從開始就可以正常工作。 多麼奇怪的小蟲子 –