Skip to content

Make Typed SetBinding() method generic so that the BindableProperty need not be prefixed with the type name #23590

@egvijayanand

Description

@egvijayanand

Description

Make the Typed SetBinding() method generic so that the BindableProperty need not be prefixed with the type name.

By doing so, all the bindable properties of the object that invokes this method will be accessible.

Public API Changes

public static void SetBinding<TBindableObject, TSource, TProperty>(this TBindableObject bindable, BindableProperty targetProperty, Func<TSource, TProperty> getter /* all other parameters */) where TBindableObject : BindableObject {}

Intended Use-Case

var lbl = new Label();
// Current scenario:
lbl.SetBinding(Label.TextProperty, static (HomeViewModel vm) => vm.FullName);

// Updated scenario
// TextProperty is now accessible in the scope
lbl.SetBinding(TextProperty, static (HomeViewModel vm) => vm.FullName);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions