Skip to content

[BUG] IconTintColorBehavior is reset when navigate to another page then back #1957

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

Open
2 tasks done
zenith6495 opened this issue Jun 20, 2024 · 20 comments · Fixed by #2304 · May be fixed by #2077 or #2495
Open
2 tasks done

[BUG] IconTintColorBehavior is reset when navigate to another page then back #1957

zenith6495 opened this issue Jun 20, 2024 · 20 comments · Fixed by #2304 · May be fixed by #2077 or #2495
Labels
area/behaviors Issue/Discussion/PR that has to do with Behaviors bug Something isn't working unverified

Comments

@zenith6495
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

IconTintColorBehavior for image is reset to black color when you navigate to another page then back to current page.

Expected Behavior

IconTintColorBehavior for image should remain the same when navigate to another page then to the current page.

Steps To Reproduce

  1. Set IconTintColorBehavior of an Image to red color for example.
  2. Navigate to another page using Shell.GotoAsync.
  3. Go back to the previous page, where icon is tinted to red.
  4. Notice the tinted image is reset back to black color.

Note: I noticed this issue in the latest version community toolkit sample project as well.

Link to public reproduction project repository

https://github.com/CommunityToolkit/Maui/tree/main/samples

Environment

- .NET MAUI CommunityToolkit: 9.0.1
- OS: Windows
- .NET MAUI: 8.0.60

Anything else?

No response

@zenith6495 zenith6495 added bug Something isn't working unverified labels Jun 20, 2024
@vhugogarcia vhugogarcia added the area/behaviors Issue/Discussion/PR that has to do with Behaviors label Jun 20, 2024
@kkppstudios
Copy link

Thanks for logging this. I'm experiencing the same issue. Also seeing the tint color reset to white after a DataTrigger changes the tint color and then changes it back.

@TheSundayDev
Copy link

TheSundayDev commented Jul 9, 2024

Thanks for this. I'm experiencing the same issue on IOS even when the app goes background and then comes back.

@myix765 myix765 linked a pull request Jul 31, 2024 that will close this issue
6 tasks
@TheSundayDev
Copy link

Hi all, just to know. this issue is also on IOS. The fix above is also for IOS?
thanks a lot

@Saurbaum
Copy link

I've noticed that by forcing a property change on the control that the image button has the behavior on will cause it to reevaluate it. Sadly this work around doesn't work if the Image buttons are in a collection.

@TheSundayDev
Copy link

Hi,
it seems that the issue is partially solved from last version of CT (9.0.2). Now when I go to a new page the color is alwasy applied. The only issue I can still see is that when I come back to prev page, if you are using behavior in list view items, the color is wrong in some elements (eg instead to be applied to 2nd element is applied to the first.. ).

@elTRexx
Copy link

elTRexx commented Oct 26, 2024

I have similar issue with a Button with an ImageSource and a IconTintColorBehavior applied. My image is an SVG (using its automatically created PNG clone in XAML definition). Going to another page and then back (using built-in back navigation button) didn't apply the custom tint of my image button. I'm using 9.1.0 version of the Toolkit, using Windows Machine. It worked though on android emulator.

@TheSundayDev
Copy link

Hi,
the bug is still open and it's the same of ths issue #2275
IconTintColorBehavior is my nightmare and it's blocking me to migrate to MAUI :(

@bijington
Copy link
Contributor

@TheSundayDev can you please try testing the result of this PR: #2304 and add in the ApplyOn property to your behavior usage? Set it to OnViewLoaded.

@TheSundayDev
Copy link

TheSundayDev commented Oct 27, 2024

@TheSundayDev can you please try testing the result of this PR: #2304 and add in the ApplyOn property to your behavior usage? Set it to OnViewLoaded.

Hi,
thanks a lot for your commitment, much appreciated! I'm going to test asap.
Just one question, since there is an issue I think that that fix should be apply by default and not setting a parameter. Am I wrong?

@bijington
Copy link
Contributor

I get your point but that would be a behavioral change. We haven't had many people report this issue so either they aren't seeing it or aren't using the behavior. If it's a common issue then it would be wise to change the default behavior

@TheSundayDev
Copy link

Thanks a lot for your super quick answer, thanks!
Can you tell me how to test your PR?
thanks

@bijington
Copy link
Contributor

@TheSundayDev you can follow this page to pull down the build from the PR: https://github.com/CommunityToolkit/Maui/wiki/Preview-Packages

@TheSundayDev
Copy link

hi,
in order to test all test must be passed?
thanks

@TheSundayDev
Copy link

Hi, no news for this PR?
thanks

@bijington
Copy link
Contributor

We have some pipeline failures which I haven't worked out the cause yet. You can probably still grab the preview build though

@WEUDE
Copy link

WEUDE commented Jan 2, 2025

Are there any updates on this item? This issue still persist.

@TheCodeTraveler TheCodeTraveler linked a pull request Feb 4, 2025 that will close this issue
6 tasks
@elTRexx
Copy link

elTRexx commented Mar 8, 2025

Hello, if you pardon me for asking for update, I though you resolved the issue, so I updated my version to last one 11.1.0, but the Icon tint color isn't correctly working (first time OK, then on back navigation not anymore). I've tested it on Windows Machine, with 2 nested navigation pages (Home -> Selected Item -> Edit Item <- Selected Item <- Home).
I saw you reverted the PR, so maybe it is still on the go for next release? Thanks.

@durandt
Copy link

durandt commented May 7, 2025

We have the same (or a similar) issue with IconTintColorBehavior.

(Note: We use a copy of IconTintColorBehavior with small changes but I can see the same behaviour whether we use our own or the one from the ToolKit)

When adding a button to a view that is visible, the IconTintColorBehavior is applied as expected.
The issue arises when we bind the Button's IsVisible property with our ViewModel and the IsVisible property is false when the IconTintColorBehavior is applied and set to true after some async loading.

We have seen the issue within our Shell and we are using <TabBar>.

One thing I have noticed is that, after loading a Button where the IconTintColorBehavior is not applied correctly, if I switch to a tab with buttons where the IconTintColorBehavior is applied correctly, then switching back to the previous tab, the button image tint color is now applied.

I have applied the changes from #2495 to our custom IconTintColorBehavior (running ApplyTintColor on Loaded-event) and the issue still persist. I may create a repro using IconTintColorBehavior directly from the PR but I cannot promise it right now because I have tight time constraints.

@bijington
Copy link
Contributor

Perhaps we need to also apply the tint when IsVisibke changes

@durandt
Copy link

durandt commented May 7, 2025

@bijington That was my first thought but it does not seem to help (I tried adding the behaviour when IsVisible changes but it still did not work).
What seems to work in my case is to only add the ImageSource to the Button when IsVisible changes to true. So I am starting to wonder if the issue is not something with the image rather than the IconTintColorBehavior (wild guesses). Something like dotnet/maui#14622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/behaviors Issue/Discussion/PR that has to do with Behaviors bug Something isn't working unverified
Projects
None yet
10 participants