- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
Description
Discussed in #13691
Originally posted by Cybrosys March  4, 2023
Hi,
I raised this Q&A and also a bug in the MCT repo:
CommunityToolkit/Maui#1054
It is a question related to doing a DynamicResource  binding against a bindable property on the StatusBarBehaior, if it is supported or a bug. If it is a bug I think it belongs here in the main MAUI repo.
Here is a link to the bug in the MCT Repo:
CommunityToolkit/Maui#1056
So, is this a bug in the MAUI repo or a limitation? For me as a developer and consumer, since the XAML does not show any error I would expect and assume that I would be able to use a DynamicResource binding for the StatusBarBehavior's StatusBarColor bindable property.
I also expressed in one of my comments that if I wanted to start investigating this, where would I start? I do not know who would own the DynamicResource binding. When doing a normal Bind I would expect it to be owned by the UI element itself, targeting a defined BindingContext. However, DynamicResource bindings seem a bit more "magical" in that they work without a BindingContext being defined/assigned.
There are several issues currently related to DynamicResource bindings not working in .NET 7 but in .NET 6. So I do not know if this problem is related to Behavors specifically or a core issue with DynamicResource.
Update
I got information here CommunityToolkit/Maui#1056 that it can't use DynamicResource because it does not inherit from VisualElement or implement IResourcesProvider.
I would argue that you should be able to use DynamicResource even when not inheriting from VisualElement. The reason being that you can put any type of value into a ResourceDictionary, so in essence it is just a normal binding where the source is the parent or app's ResourceDictionary.