-
Notifications
You must be signed in to change notification settings - Fork 405
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
[BUG] Image tint color behavior doesn't get applied from DynamicResource or ViewModel #775
Comments
Are there any updates? The problem also seems to exists with an ImageButton. |
@hemantbeast in order to make the Binding working from a VM, you need to set the BindingContext on your behavior. |
@pictos Thank you for your suggestion. I tried it: I am using .NET6 with version 2.0.0 of the NET MAUI CommunityToolkit. Running it on a Android Emulator with version 27 of the Android API. PS for now, I have a workaround updating the TintColor from the code behind. |
Also getting an issue with tint colour behaviour and not responding to AppThemeBindings As well as this, if the source is set as a binding, when the image source updates it seems to remove the tint behaviour and defaults back to white |
We're running also into this or similar issue.
By the way:
|
@pictos the issue is with the current behavior system, as in Xamarin.Forms there isn't any issue using it with the Effects. Whereas in this the property gets registered once & didn't get update on change. The solution is to set the new behavior on every property change in the page.cs file which is also not a good practice. |
@hemantbeast I believe there's a lack of information here... So behaviors works in a different manner, from docs you can see this:
So, you need to pass your BindingContext to the behavior or use a relative Binding in order make it work with your VM or anything bindable (Not sure about the AppThemeBinding). For more info about more complex ways to do Bidings please see this doc and this one |
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 Once Once it's documented, let's close this Issue. |
I tried this,
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? |
Is there an existing issue for this?
Current Behavior
On setting the
IconTintColorBehavior
in Image, theTintColor
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
Link to public reproduction project repository
https://github.com/hemantbeast/StatusBarSample/tree/tint_color
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: