Maui
Maui copied to clipboard
[BUG] IconTintColorBehavior is reset when navigate to another page then back
Is there an existing issue for this?
- [X] I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
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
- Set IconTintColorBehavior of an Image to red color for example.
- Navigate to another page using Shell.GotoAsync.
- Go back to the previous page, where icon is tinted to red.
- 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
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.
Thanks for this. I'm experiencing the same issue on IOS even when the app goes background and then comes back.
Hi all, just to know. this issue is also on IOS. The fix above is also for IOS? thanks a lot
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.
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.. ).
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.
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 :(
@TheSundayDev can you please try testing the result of this PR: https://github.com/CommunityToolkit/Maui/pull/2304 and add in the ApplyOn property to your behavior usage? Set it to OnViewLoaded.
@TheSundayDev can you please try testing the result of this PR: #2304 and add in the
ApplyOnproperty to your behavior usage? Set it toOnViewLoaded.
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?
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
Thanks a lot for your super quick answer, thanks! Can you tell me how to test your PR? thanks
@TheSundayDev you can follow this page to pull down the build from the PR: https://github.com/CommunityToolkit/Maui/wiki/Preview-Packages
hi, in order to test all test must be passed? thanks
Hi, no news for this PR? thanks
We have some pipeline failures which I haven't worked out the cause yet. You can probably still grab the preview build though
Are there any updates on this item? This issue still persist.
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.
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.
Perhaps we need to also apply the tint when IsVisibke changes
@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 https://github.com/dotnet/maui/issues/14622