StyleSelector StyleSelector StyleSelector Class

Enables custom item style selection logic as a function of the content data and its specific item container.

Syntax

Declaration

public class StyleSelectorpublic class StyleSelectorPublic Class StyleSelector
See Remarks

Remarks

The base StyleSelector class is not used as an object element in XAML. However, it is a common scenario to derive a custom StyleSelector, map a xmlns prefix for the custom class and its namespace/assembly, and then refer to an instance of the custom class as defined in a Resources block in XAML. This makes it possible to refer to the custom template selector class by x:Key, and use that reference to set the value of properties such as ItemContainerStyleSelector in XAML templates and particular visual states.

Constructors summary

Initializes a new instance of the StyleSelector class.

Methods summary

Returns a specific Style based on custom logic.

When implemented by a derived class, returns a specific Style based on custom logic.

Constructors

  • StyleSelector()
    StyleSelector()
    StyleSelector()
    StyleSelector()

    Initializes a new instance of the StyleSelector class.

    public StyleSelector()public New()Public Sub New()public StyleSelector()

Methods

  • SelectStyle(Object, DependencyObject)
    SelectStyle(Object, DependencyObject)
    SelectStyle(Object, DependencyObject)
    SelectStyle(Object, DependencyObject)

    Returns a specific Style based on custom logic.

    public Style SelectStyle(Object item, DependencyObject container)public Style SelectStyle(Object item, DependencyObject container)Public Function SelectStyle(item As Object, container As DependencyObject) As Stylepublic Style SelectStyle(Object item, DependencyObject container)

    Parameters

    Returns

    • An application-specific style to apply; may also return null.

    Remarks

    To provide a specific style in a derived class, override the SelectStyleCore(Object, DependencyObject) method.

  • SelectStyleCore(Object, DependencyObject)
    SelectStyleCore(Object, DependencyObject)
    SelectStyleCore(Object, DependencyObject)
    SelectStyleCore(Object, DependencyObject)

    When implemented by a derived class, returns a specific Style based on custom logic.

    protected virtual Style SelectStyleCore(Object item, DependencyObject container)protected virtual Style SelectStyleCore(Object item, DependencyObject container)Protected Overridable Function SelectStyleCore(item As Object, container As DependencyObject) As Styleprotected virtual Style SelectStyleCore(Object item, DependencyObject container)

    Parameters

    Returns

    • An application-specific style to apply; may also return null.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ComposableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Controls.dll