docs-maui
docs-maui copied to clipboard
.NET MAUI 9: Compiled bindings can be used with C# markup
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