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

Setter using DynamicResource is not reapplied when related trigger condition is updated #13585

Closed
dilyantraykov opened this issue Feb 27, 2023 · 3 comments · Fixed by #16578
Closed
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@dilyantraykov
Copy link

dilyantraykov commented Feb 27, 2023

Description

Assume the following style which is applied to a Button element:

        <Color x:Key="MyPrimaryColor">Green</Color>
        <Color x:Key="MyReadOnlyColor">Purple</Color>

        <Style TargetType="Button" x:Key="MyDynamicResourceButtonStyle">
            <Setter Property="BackgroundColor" Value="{DynamicResource MyPrimaryColor}" />
            <Style.Triggers>
                <Trigger TargetType="Button" Property="IsEnabled" Value="False" >
                    <Setter Property="BackgroundColor" Value="{DynamicResource MyReadOnlyColor}" />
                </Trigger>
            </Style.Triggers>
        </Style>

When the button's IsEnabled property is changed to True after initially being False (for example upon a button click), the BackgroundColor property is not updated as expected. The issue is not present when using StaticResource instead.

Steps to Reproduce

  1. Open the project from the referenced reproduction repository.
  2. Click on any of the Start buttons.

Expected: Both Stop buttons have a Green background color.
Actual: Only the top Stop button (using StaticResource) has a Green background. The Button using the DynamicResource keeps its Purple color.

Link to public reproduction project repository

https://github.com/dilyantraykov/DynamicResourceIssueIsolation

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

Android 33, Windows SDK 10.0.19041.0, iOS, MacCatalyst

Did you find any workaround?

One workaround is to use a StaticResource instead of a DynamicResource.
Another way around this is to explicitly define separate triggers for all the possible values for the styled property which may not be sustainable in most cases.

Relevant log output

No response

@dilyantraykov dilyantraykov added the t/bug Something isn't working label Feb 27, 2023
@rmarinho rmarinho added the area-xaml XAML, CSS, Triggers, Behaviors label Feb 27, 2023
@rmarinho rmarinho added this to the Backlog milestone Feb 27, 2023
@ghost
Copy link

ghost commented Feb 27, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@jinxinjuan jinxinjuan added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Jun 13, 2023
@jinxinjuan
Copy link

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Can repro on windows, android and iOS platform with sample project. DynamicResourceIssueIsolation

@StephaneDelcroix
Copy link
Contributor

We did some major rewrites of Styles and Setters in main and net8. I no longer can reproduce your problem on top of the new code. I've added a unitest fo this particular issue.

Please reopen this issue, or modify the unit test if your issue isn't resolved

rmarinho pushed a commit that referenced this issue Aug 7, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 Aug 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2023
@samhouts samhouts added the fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 label Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants