Skip to content

VisualState does not obey style hierarchy rules #28535

Open
@lendres

Description

@lendres

Description

When using VisualStates they do not appear to obey the rules of style hierarchies. Styles defined at the page level do not seem to correctly override styles defined at the app level.

Steps to Reproduce

  1. Clone and compile the repository specified below (use the main branch).
  2. Note that there are Label and Picker styles defined in the Styles.xaml document as well as at the top of the MainPage.
  3. Run the app and note the appearance of the controls. The styles in the MainPage do not seem to override those defined in the Styles.xaml for the VisualStates. If correct, the text should be red. The styles that are directly assigned using x:Key function as expected.
    Image
  4. Toggle the Switch to enable the controls. Note that style properties set without the use of VisualStates do override those in the Styles.xaml document (all the text is green).
    Image

Based on the documentation, I would expect styles defined at the page level to override those at the app level. I would expect that for the visual states as well and the result would be both sets of controls (Override and Assigned) to function the same.

Link to public reproduction project repository

https://github.com/lendres/MauiPickerVisualStates

Version with bug

9.0.50 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

Windows

Affected platform versions

Windows 10.0.19041.0

Did you find any workaround?

The styles can be explicitly set using the Style or StyleClass attributes.

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorsplatform/windows 🪟s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions