docs-maui icon indicating copy to clipboard operation
docs-maui copied to clipboard

.NET MAUI 9: Compiled bindings can be used with C# markup

Open davidbritch opened this issue 1 year ago • 1 comments

In .NET MAUI 9, compiled bindings can be used with C# markup (to replace reflection-based bindings with string paths).

Example:

// in .NET 8
MyLabel.SetBinding(Label.TextProperty, "Text");

// in .NET 9
MyLabel.SetBinding(Label.TextProperty, static (Entry entry) => entry.Text);

This new approach has several advantages:

  • better performance (benefits are already summarized in the docs: https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/data-binding/compiled-bindings?view=net-maui-8.0#performance)
  • intellisense while editing
  • compile-time check of path validity

More info: https://github.com/dotnet/maui/pull/21725


Associated WorkItem - 314390

davidbritch avatar Jun 11 '24 11:06 davidbritch