-
Compiled bindings improve data binding performance in .NET MAUI applications. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 16 replies
-
For Compiled Bindings in C#, you need to install the DocsExampleusing static CommunityToolkit.Maui.Markup.GridRowsColumns;
class SampleContentPage : ContentPage
{
public SampleContentPage()
{
Content = new Grid
{
RowDefinitions = Rows.Define(
(Row.TextEntry, 36)),
ColumnDefinitions = Columns.Define(
(Column.Description, Star),
(Column.Input, Stars(2))),
Children =
{
new Label()
.Text("Code:")
.Row(Row.TextEntry).Column(Column.Description),
new Entry
{
Keyboard = Keyboard.Numeric,
BackgroundColor = Colors.AliceBlue,
}.Row(Row.TextEntry).Column(Column.Input)
.FontSize(15)
.Placeholder("Enter number")
.TextColor(Colors.Black)
.Height(44)
.Margin(5, 5)
.Bind(Entry.TextProperty, static (ViewModel vm) vm => vm.RegistrationCode)
}
};
}
enum Row { TextEntry }
enum Column { Description, Input }
} |
Beta Was this translation helpful? Give feedback.
-
Ok, this code is indeed "compiled", and not using a |
Beta Was this translation helpful? Give feedback.
-
Hi Brandon, I've done more testing of compiled/typed bindings, both with xaml and c#. Here are my conclusions:
Here is the code I've used to benchmark the different cases: https://github.com/tranb3r/Issues/tree/main/BenchmarkBindings Here are the results of my benchmarks (higher is better): So, here are my questions:
|
Beta Was this translation helpful? Give feedback.
-
Closed as answered |
Beta Was this translation helpful? Give feedback.
-
Coming up to a year for this discussion is it ok to close? |
Beta Was this translation helpful? Give feedback.
For Compiled Bindings in C#, you need to install the
CommunityToolkit.Maui.Markup
NuGet Package.Docs
https://learn.microsoft.com/dotnet/communitytoolkit/maui/markup/extensions/bindable-object-extensions#one-way-binding
Example