You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81-67Lines changed: 81 additions & 67 deletions
Original file line number
Diff line number
Diff line change
@@ -1107,6 +1107,87 @@ public class UsersView : DocumentView<UsersViewModel>
1107
1107
1108
1108
The `BindableScrollView` has the same binding logic as the `BindableListView`. It does not use virtualization and creates VisualElements for all items regardless of visibility.
1109
1109
1110
+
#### BindingContextProvider
1111
+
1112
+
The `BindingContextProvider` allows you to provide a custom `IBindingContext` for all child elements.
To provide the `CustomViewModel` as a binding context for certain elements, we have to use the `BindingContextProvider` as the parent for those elements.
In this example, `Label1` and `Label2` will display the text "Main Context", while `Label3` will display the text "Custom Context".
1163
+
1164
+
We can create a `BindingContextProvider` for a specific `IBindingContext` to avoid allocating memory for a new `PropertyCastWrapper` class. Let's create a `CustomViewModelProvider` element.
To provide the `CustomViewModel` as a binding context for certain elements, we have to create a `BindingContextProvider` and use it as the parent for those elements.
In this example, `Label1` and `Label2` will display the text "Main Context", while `Label3` will display the text "Custom Context".
1271
-
1272
1286
### Source code generator
1273
1287
1274
1288
The best way to speed up the creation of custom `VisualElement` is to use source code generators. With this powerful tool, you can achieve the same great results with minimal boilerplate code and focus on what really matters: programming!
0 commit comments