You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ObservableProperty]
private Color _statusBarColorProp;
Update the property value in code-behind or model like StatusBarColorProp=Color.FromRgb(255,0,0). You'll see status bar color does not change with StatusBarBehavior property change in runtime. Same for all the rest of behaviors. It works fine for non-bindings setters like StatusBarColor="Red".
Description
Binding to observable property does not work in platform behaviors. Try any platform behavior community mvvm toolkit provides:
https://github.com/CommunityToolkit/Maui/tree/main/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors
or create your own, you would get the same result.
Here is an original stackoverflow thread https://stackoverflow.com/questions/74607699/binding-does-not-work-for-platform-dependent-behaviors
Steps to Reproduce
Take for example
StatusBarBehavior
, write something likecreate the property in your view model
Update the property value in code-behind or model like
StatusBarColorProp=Color.FromRgb(255,0,0)
. You'll see status bar color does not change with StatusBarBehavior property change in runtime. Same for all the rest of behaviors. It works fine for non-bindings setters like StatusBarColor="Red".Link to public reproduction project repository
https://github.com/CommunityToolkit/Maui/tree/main/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
I was not able test on other platforms
Affected platform versions
at least Android API 32 that I tested on, but does not seem to be platform dependent
Did you find any workaround?
interestingly while binding does not work for viewmodel, it does if you bind it to other control.
For example if you take BlurBehaviour from the repository https://github.com/VladislavAntonyuk/MauiSamples/tree/main/MauiImageEffects.
This code works fine:
But this one does not
Relevant log output
No response
The text was updated successfully, but these errors were encountered: