Automatically Set Binding in Behaviors #2417
Replies: 2 comments 1 reply
-
@david-maw since Xamarin.Forms Behaviors doesn't set the BindingContext automatically. You can see that info in docs |
Beta Was this translation helpful? Give feedback.
-
Sorry, I'd assumed the Community Toolkit change was reflecting some change in .NET MAUI, obviously not. That means my suggestion comes down to "please don't introduce this breaking change in the Community Toolkit Behaviors". Do you (or anyone for that matter) know what it is about Behaviors that makes it problematic for them to inherit BindingContext? I get that they can be specified in Style entries, but so can many other properties, so what's special about Behaviors? |
Beta Was this translation helpful? Give feedback.
-
The new .NET 9 implementation of not setting BindingContext in a behavior is a pain, it leads to XAML like:
Would it be reasonable to set Biding automatically using something like this (this example is for an Entry, but I think it can be generalized:
This just sets the binding to that of the parent if it is null at attach time and remembers it did it so it can be undone when detached.
It would obscure the fact that BindingContext is not set by default for .NET 9 Behaviors, but I don't really understand the argument for not setting BindingContext, since almost any property could be set in a style. It would be better to do this in the framework, but that's what just changed!
Beta Was this translation helpful? Give feedback.
All reactions