Icon Tint Color Behavior does not color images on IOS under certain conditions
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Did you read the “Reporting a bug” section on Contributing file?
- 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
I am trying to color icons at runtime in a collectionview based on AppthemeBinding using Maui Community Toolkit IconTint Behavior. The process in the content page loops through each process which queries a server database, once completed the egg timer icon gets replaced with a tick icon based on the response from the server.
For testing purposes i’m using an Await.Delay(500) to simulate the server trip, this is mostly functioning correctly with the exception that the icon tint behavior does not get applied and retains its original color, this is only happening on IOS, on Android it works perfectly. This has also happened on several other views where i have an Await.Delay(), as soon as i remove this, the behavior gets applied. The data is in an observable collection within a collectionview.
Also, if I put an Await.Delay before using Shell.Current.GoToAsync, the icons on my custom navigation bar retain their original color.
Expected Behavior
I’m expecting the icons to adopt the new color like they do when running on android.
Steps To Reproduce
Create a Content Page, in XAML
<Image Source="check" WidthRequest="80" HeightRequest="80" > <Image.Behaviors> <mct:IconTintColorBehavior TintColor="Orange" /> </Image.Behaviors> </Image>In the code behind or VM: await Task.Delay(1000); await Shell.Current.GoToAsync(nameof(Test_landing));
Run on IOS, the icon retains it’s original color, run on Android and it adopts the new color
Remove the await Task.Delay and it works fine. I’m using await delay to allow a popup page that I have close then displaying a new page based on the selection.
Link to public reproduction project repository
https://github.com/SteveJML/Tint-Image-Test
Environment
- .NET MAUI CommunityToolkit:
- OS:
- .NET MAUI:
Anything else?
Images in a collection view cannot be coloured per item based on the binding. I have images that I wanted to color based on their extension, ie .pdf, docx etc.
Issue Analytics
- State:
- Created 5 months ago
- Comments:5 (3 by maintainers)
@SteveJML looks like this is more a Maui issue than us… The workaround is to add the Behavior on the Loaded event on the page, just like this:
WHen I did that change it worked 100% of the time
@SteveJML if you can rise the issue there, it will be great. The root cause is that
img.Loaded
didn’t trigger, so the IconTintColor behavior will not work