-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Epic: Add new SetBinding API for defining "compiled" bindings in code #22384
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
|
In this proposal #20574, the generated method partial class StudentDetailPage
{
private static BindingBase StudentFirstNameBinding(
object? source = null,
BindingMode mode = BindingMode.OneWay, // default value based on the attribute value
IValueConverter? converter = null,
object? converterParameter = null,
string? stringFormat = null,
object? targetNullValue = null,
object? fallbackValue = null)
=> ...;
} it would be this partial class StudentDetailPage
{
private static BindingBase StudentFirstNameBinding<TSource, TProperty>(
TSource? source = null,
BindingMode mode = BindingMode.OneWay, // default value based on the attribute value
IValueConverter? converter = null,
object? converterParameter = null,
[System.Diagnostics.CodeAnalysis.StringSyntax] string? stringFormat = null,
TProperty? targetNullValue = null,
TProperty? fallbackValue = null)
=> ...;
} Same thing with public static partial class BindableObjectExtensions
{
public static void SetBinding<TSource, TProperty>(
this TSource self,
BindableProperty property,
Func<TSource, TProperty> getter,
Action<TSource, TProperty>? setter = null,
BindingMode mode = BindingMode.Default,
IValueConverter? converter = null,
object? converterParameter = null,
[System.Diagnostics.CodeAnalysis.StringSyntax] string? stringFormat = null,
object? source = null,
TProperty? fallbackValue = null,
TProperty? targetNullValue = null) where TSource : BindableObject
{
throw new InvalidOperationException($"The method call to {nameof(SetBinding<TSource, TProperty>)} was not intercepted.");
}
} Also, would it be useful to think about introducing a generic Finally, keep up the good work 💪 |
This new API has been released and is part of .NET MAUI 9 RC 1. |
We agreed to implement a new public API to allow creating "compiled" bindings (
TypedBinding<TSource, TProperty>
) in code via source-generators and interceptors based on the proposal #20574 (see Alternative design).BindableObjectExtensions.SetBinding<TSource, TProperty>(BindableProperty property, Func<TSource, TProperty> getter, ...)
as defined in the proposalSetBinding<TSource, TProperty>(...)
as
-castsWrite docs/developer guide- tracked in .NET MAUI 9: Compiled bindings can be used with C# markup docs-maui#2304Possible future improvements
TypedBinding.ForSingleNestingLevel(...)
with the source generated interceptors - [Binding SG] Dogfood binding source generator in the MAUI codebase #23393BindingBase Binding.Create<TSource, TProperty>(Func<TSource, TProperty> getter, ...)
TBindable Bind<TBindable, TSource, TProperty>(this TBindable bindableObject, Func<TSource, TProperty> getter, ...) where TBindable : BindableObject
.SetBinding
with the samegetter
signature into one interceptorThe text was updated successfully, but these errors were encountered: