Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 1.87 KB

datatemplate_getelement_445960756.md

File metadata and controls

36 lines (21 loc) · 1.87 KB
-api-id -api-type
M:Microsoft.UI.Xaml.DataTemplate.GetElement(Microsoft.UI.Xaml.ElementFactoryGetArgs)
winrt method

Microsoft.UI.Xaml.DataTemplate.GetElement

-description

Creates or retrieves an existing instance of the UIElement object declared in the DataTemplate.

-parameters

-param args

An instance of ElementFactoryGetArgs.

-returns

An instance of the root UIElement declared in the DataTemplate or null if the root of the DataTemplate is not a UIElement.

-remarks

The DataTemplate acts as a factory that generates the element object declared in its template. Unlike the LoadContent method that creates a new instance every time it is invoked, the GetElement method may either create a new instance or return an existing instance that was recycled via RecycleElement.

The DataTemplate's implementation of GetElement does not use the Data value from the ElementFactoryGetArgs. The Data property exists for implementations such as DataTemplateSelector where it is used to decide from which DataTemplate to load content.

-see-also

IElementFactory, DataTemplate.RecycleElement, DataTemplateSelector.GetElement, DataTemplateSelector.RecycleElement

-examples