-api-id | -api-type |
---|---|
M:Microsoft.UI.Xaml.DataTemplate.LoadContent |
winrt method |
Creates the UIElement objects in the DataTemplate.
The root UIElement of the DataTemplate.
When you call LoadContent, the UIElement objects in the DataTemplate are created, and you can add them to the visual tree of another UIElement.
The following examples demonstrate using the LoadContent method to change the appearance of a Border at run time. The example creates a ListView that contains the numbers 1 through 10. When the user selects an item in the ListView, the Border displays the selected number. If the user selects an even number, the number is red and has a green circle around it. If the user selects an odd number, the number is blue and has a purple square around it.
[!code-xamlSnippet2_XAML]
[!code-csharpSnippet2_CS]