Version

TemplateSelector Property

Returns/sets a DataTemplateSelector implementation that will return the DataTemplate to use for displaying/editing the property value.
Syntax
'Declaration
 
Public Property TemplateSelector As DataTemplateSelector
public DataTemplateSelector TemplateSelector {get; set;}
Remarks

Note: If a DataTemplateSelector instance is assigned to this property, the control will call its SelectTemplate method to obtain the DataTemplate to use for displaying/editing the property value. If the SelectTemplate method returns null, then the control will use the built-in editor associated with the property's type. Although the EditTemplate and ReadOnlyTemplate properties are ignored by the XamPropertyGrid when this property is set, those DataTemplates (if specified) are passed to the DataTemplateSelector's SelectTemplate method in a PropertyGridTemplateSelectorContext instance as described below, and the SelectTemplate implementation is free to return one of them as the DataTemplate that should be used to display/edit the property value.

Note: The SelectTemplate method of the DataTemplateSelector will be called with an instance of a PropertyGridTemplateSelectorContext object passed via the method's 'item' parameter. This PropertyGridTemplateSelectorContext instance exposes several properties that the SelectTemplate method can use to determine which DataTemplate (if any) should be returned:

PropertyGridTemplateSelectorContext.PropertyItem The PropertyGridPropertyItem associated with the property whose DataTemplate is being selected.
PropertyGridTemplateSelectorContext.EditTemplate The DataTemplate instance assigned to the EditTemplate property which the SelectTemplate implementation can choose to return as the selected template.
PropertyGridTemplateSelectorContext.ReadOnlyTemplate The DataTemplate instance assigned to the ReadOnlyTemplate property which the SelectTemplate implementation can choose to return as the selected template.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also