Windows 10 UWP 两个自适应触发器未按预期工作
Windows 10 UWP Two Adaptive Triggers not working as expected
我有针对不同屏幕分辨率的 VisualStateGroups。如果我将 window 从小调整为大,一切都按预期工作。但是,如果我将 window 从大调整为小,第一个视觉状态组将被忽略,并且 windows 布局将跳回到控件本身定义的布局。
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="720"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelAmount"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="900"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelRemainingTime.(RelativePanel.RightOf)" Value="labelFee"/>
<Setter Target="labelRemainingTime.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelRemainingTime.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
对不起各位,我自己发现了。触发器需要在同一个 VisualStateGroup 元素中才能像我希望的那样工作。
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="720"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelAmount"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="900"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelRemainingTime.(RelativePanel.RightOf)" Value="labelFee"/>
<Setter Target="labelRemainingTime.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelRemainingTime.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
我有针对不同屏幕分辨率的 VisualStateGroups。如果我将 window 从小调整为大,一切都按预期工作。但是,如果我将 window 从大调整为小,第一个视觉状态组将被忽略,并且 windows 布局将跳回到控件本身定义的布局。
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="720"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelAmount"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="900"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelRemainingTime.(RelativePanel.RightOf)" Value="labelFee"/>
<Setter Target="labelRemainingTime.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelRemainingTime.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
对不起各位,我自己发现了。触发器需要在同一个 VisualStateGroup 元素中才能像我希望的那样工作。
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="720"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelAmount"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<!--VisualState to be triggered when window width is >= ??? effective pixels.-->
<AdaptiveTrigger MinWindowWidth="900"></AdaptiveTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="labelFee.(RelativePanel.RightOf)" Value="labelAmount"/>
<Setter Target="labelFee.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelFee.Margin" Value="10,3,3,0"/>
<Setter Target="labelRemainingTime.(RelativePanel.RightOf)" Value="labelFee"/>
<Setter Target="labelRemainingTime.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelRemainingTime.Margin" Value="10,3,3,0"/>
<Setter Target="labelLendingDate.(RelativePanel.RightOf)" Value="labelRemainingTime"/>
<Setter Target="labelLendingDate.(RelativePanel.Below)" Value="labelRate"/>
<Setter Target="labelLendingDate.Margin" Value="10,3,3,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>