diff --git a/docs/fundamentals/data-binding/compiled-bindings.md b/docs/fundamentals/data-binding/compiled-bindings.md index afccfa913..d2c60455d 100644 --- a/docs/fundamentals/data-binding/compiled-bindings.md +++ b/docs/fundamentals/data-binding/compiled-bindings.md @@ -1,7 +1,7 @@ --- title: "Compiled bindings" description: "Compiled bindings can be used to improve data binding performance in .NET MAUI applications." -ms.date: 10/29/2024 +ms.date: 11/14/2024 --- # Compiled bindings @@ -120,45 +120,21 @@ Bindings in a are interpreted in the The following example demonstrates correctly setting the `x:DataType` on a : ```xaml - - - ... - - - - - - - - - - - - - - + + + + + + + + + ``` -The `ListView.ItemsSource` property is set to the static `NamedColor.All` property. The `NamedColor` class uses .NET reflection to enumerate all the static public fields in the class, and to store them with their names in a collection that is accessible from the static `All` property. Therefore, the is filled with all of the `NamedColor` instances. For each item in the , the binding context for the item is set to a `NamedColor` object. The and elements in the are bound to `NamedColor` properties. - -The defines the `x:DataType` attribute to be the `NamedColor` type, indicating that any binding expressions in the view hierarchy will be compiled. This can be verified by changing any of the binding expressions to bind to a non-existent `NamedColor` property, which will result in a build error. While this example sets the `x:DataType` attribute to a string literal, it can also be set to a type with the `x:Type` markup extension. For more information about the `x:Type` markup extension, see [x:Type Markup Extension](~/xaml/markup-extensions/consume.md#xtype-markup-extension). - -When the example is first run, the is populated with `NamedColor` instances. When an item in the is selected, the `BoxView.Color` property is set to the color of the selected item in the : - -:::image type="content" source="media/compiled-bindings/compiledcolorlist.png" alt-text="Compiled color list."::: - -Selecting other items in the updates the color of the . +While this example sets the `x:DataType` attribute to a string literal, it can also be set to a type with the `x:Type` markup extension. For more information about the `x:Type` markup extension, see [x:Type Markup Extension](~/xaml/markup-extensions/consume.md#xtype-markup-extension). ::: moniker range=">=net-maui-9.0" @@ -174,8 +150,8 @@ Then, ensure that all your bindings are annotated with the correct `x:DataType` ```xaml - ``` diff --git a/docs/fundamentals/data-binding/media/compiled-bindings/compiledcolorlist.png b/docs/fundamentals/data-binding/media/compiled-bindings/compiledcolorlist.png deleted file mode 100755 index f4f08e5cb..000000000 Binary files a/docs/fundamentals/data-binding/media/compiled-bindings/compiledcolorlist.png and /dev/null differ