question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Image tint color behavior doesn't get applied from DynamicResource or ViewModel

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

On setting the IconTintColorBehavior in Image, the TintColor property is working on setting colors directly or by any StaticResource. But it isn’t working when setting the TintColor as DynamicResource or a binding property from ViewModel.

Expected Behavior

<Image HeightRequest="30" WidthRequest="30" Source="ic_notification"> <Image.Behaviors> <toolkit:IconTintColorBehavior TintColor="{Binding ChangedColor}" /> </Image.Behaviors> </Image>

This should also work like it was working in XF with the Effects.

Steps To Reproduce

  1. Open and run the solution from reproduction repository
  2. Click the change button & see there is no effect.

Link to public reproduction project repository

https://github.com/hemantbeast/StatusBarSample/tree/tint_color

Environment

- .NET MAUI CommunityToolkit: 3.0.0
- OS: Mac OS 13.0.1
- .NET MAUI: 7.0

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
programatixcommented, Dec 15, 2022

I tried this,

<ImageButton Source="...">
  <ImageButton.Behaviors>
    <toolkit:IconTintColorBehavior
      TintColor="{AppThemeBinding Dark=#ff0000, Light=#00FF00}"
      BindingContext="{Binding BindingContext, Source={RelativeSource AncestorType={x:Type ImageButton}}}" />
  </ImageButton.Behaviors>
</ImageButton

and it caused System.InvalidOperationException: ‘Operation is not valid due to the current state of the object.’

Perhaps the developer should provide us, the dummies with some sample in the documentation?

1reaction
brminnickcommented, Dec 14, 2022

Thanks @pictos!

Could you do us a favor and update our Community Toolkit docs to add this info? I know it’s a bit repetitive since the .NET MAUI docs already document it, but I imagine we’ll continue to get Issues + Discussions opened around this topic if we don’t.

I think the best way for us to implement this information in every Behavior doc is to add a new file, communitytoolkit-behavior.md, to the includes/ folder, similar to how we created communitytoolkit-converter.md to describe common functionality included in all converters.

Once includes/communitytoolkit-behavior.md is created with this binding information included, then we can add it to each *-behavior.md doc file, similar to how we include the snippet from communitytoolkit-converter.md in each Converter doc.

Once it’s documented, let’s close this Issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] IconTintColorBehavior to change TintColor at ...
Using .Net Maui Community Toolkit to change the TintColor at runtime. DynamicResource is not working. Expected Behavior. DynamicResource works ...
Read more >
Using Tint color on UIImageView - ios
I would like to paint it over the image with a tint color but it doesn't work. So far I have: - (id)initWithFrame:(CGRect)frame...
Read more >
Bug - Transitions breaks background-color and image tint ...
I encountered this bug after upgrading from 2022.1.22f1 to 2022.2.1f1, here's how to reproduce it: Create a simple UXML view, like this one:...
Read more >
IconTintColorBehavior - .NET MAUI Community Toolkit
The IconTintColorBehavior is a behavior allows you to tint an image.
Read more >
Tint color not working in IOS storyboard designer.
I am having trouble getting the tint color to work in the storyboard designer. I added an image (icon) to my assets and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found