Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdaptiveTriggers' order declared in XAML shouldn't matter #2662

Closed
3 of 4 tasks
MatFillion opened this issue Feb 17, 2020 · 1 comment · Fixed by #11516
Closed
3 of 4 tasks

AdaptiveTriggers' order declared in XAML shouldn't matter #2662

MatFillion opened this issue Feb 17, 2020 · 1 comment · Fixed by #11516
Assignees
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)

Comments

@MatFillion
Copy link
Contributor

Current behavior

Take this code with 2 very small AdaptiveTriggers(0 and 10) that most likely are always "true". (not very useful, but proving the point)

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="SizeGroup">
            <VisualState x:Name="Large">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="10"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="Root.Background"
                            Value="Yellow"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState x:Name="Small">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="0"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="Root.Background"
                            Value="Red"/>
                </VisualState.Setters>
            </VisualState>
        </VisualStateGroup>

and the same triggers but listed in a different order

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="SizeGroup">
            <VisualState x:Name="Small">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="0"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="Root.Background"
                            Value="Red"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState x:Name="Large">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="10"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="Root.Background"
                            Value="Yellow"/>
                </VisualState.Setters>
            </VisualState>
        </VisualStateGroup>

Observe on UWP both code render the same thing (background is yellow) but with Uno they seem to be evaluated in the order they are declared in XAML.

Expected behavior

Same behavior as UWP. The order declared in XAML shouldn't affect the rendered result.

How to reproduce it (as minimally and precisely as possible)

Make a new Uno app using the template and paste the above code.

Environment

Nuget Package: 2.0

  • iOS
  • Android
  • WebAssembly
  • macOS (didn't test)
@MatFillion MatFillion added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Feb 17, 2020
@jeromelaban jeromelaban removed the triage/untriaged Indicates an issue requires triaging or verification label Feb 17, 2020
@MatFillion MatFillion changed the title AdaptiveTriggers are not applied in the correct order. AdaptiveTriggers' order declared in XAML shouldn't matter. Feb 17, 2020
@francoistanguay francoistanguay modified the milestone: 3.1 Aug 29, 2020
@agneszitte agneszitte added the project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..) label Sep 21, 2020
@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@MartinZikmund MartinZikmund added difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI area/eu and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jun 1, 2021
@jeromelaban jeromelaban changed the title AdaptiveTriggers' order declared in XAML shouldn't matter. AdaptiveTriggers' order declared in XAML shouldn't matter Nov 10, 2021
@ajoh504 ajoh504 mentioned this issue Nov 4, 2022
6 tasks
@agneszitte
Copy link
Contributor

agneszitte commented Feb 24, 2023

FYI @jeromelaban

This issue is still happening with the latest Uno.UI stable version 4.7.44 and latest dev version 4.8.0-dev.560

Another snippet to test the issue:

<Grid>
        <!-- ISSUE : https://github.com/unoplatform/uno/issues/2662 -->
        <!-- The WIDE VisualState.StateTriggers are not working on the other platforms here after the NARROW  VisualState.StateTriggers -->
        <!-- The VisualState.StateTriggers are working fine on Windows with this snippet of code for NARROW and WIDE (the order doesn`t matter) -->
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="NarrowApp">
                    <!-- Windows and all the other platforms needs <AdaptiveTrigger MinWindowWidth="0" /> in this case here 
                         to properly manage the setters for the Narrow visual state between 0 and 800 for the Width -->
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="BorderTest.Background"
                                Value="LightPink" />
                        <Setter Target="TextBlockTest.Text"
                                Value="Test Narrow" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="WideApp">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="800" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="BorderTest.Background"
                                Value="Orange" />
                        <Setter Target="TextBlockTest.Text"
                                Value="Test Wide" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Border x:Name="BorderTest"
                Margin="20"
                Background="LightBlue">
            <TextBlock x:Name="TextBlockTest"
                       Text="Test" />
        </Border>
    </Grid>

The StatesTriggers listed the other way around will work fine for WIDE but not for NARROW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/bug Something isn't working project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants