Reputation: 69
I have been trying to make some changes to the UI in my code depending on the screen size. As I started to code in UWP everything worked as it should, but when changing to the web assembly no changes happened when changing the size of the window, it only takes the first visual state of MinWindowWidth="0".
Here some test code that I ran. testing code
Am I missing something?
Upvotes: 1
Views: 155
Reputation: 867
Try to write it like this
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SizeGroup">
<VisualState x:Name="Large">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1000"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MainContent.Background"
Value="Blue"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Small">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MainContent.Background"
Value="Red"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
The order declared in XAML is important, so you should declare the largest MinWindowWidth
first and then the smaller ones. In your case the small one with Value 0 is evaluated first and always true.
You can track the bug here
Upvotes: 2