Skip to main content
All docs
V26.1
  • FilterElement.FilterModelTemplateSelector Property

    Gets or sets a template selector that applies a visual template to the filter element based on its model type.

    Namespace: DevExpress.Xpf.Core.FilteringUI

    Assembly: DevExpress.Xpf.Grid.v26.1.dll

    Declaration

    public DataTemplateSelector FilterModelTemplateSelector { get; set; }

    Property Value

    Type Description
    DataTemplateSelector

    A DataTemplateSelector that selects a visual template based on the filter element’s model type.

    Remarks

    Use FilterModelTemplateSelector when a filter element can produce different model types depending on the underlying column type. Unlike FilterModelTemplate that applies a single template regardless of the model type, FilterModelTemplateSelector allows you to define distinct editor templates for each supported model type.

    The selector receives the current FilterModel instance as a data item. Use the model’s type to return the appropriate template.

    Note

    FilterModelTemplateSelector has priority over FilterModelTemplate when both properties are assigned.

    Example: Create Different Filter Models Based on Column Types

    A DateRangeFilterElement creates different filter models depending on the column type:

    • DateRangeFilterModel for DateTime columns
    • DateOnlyRangeFilterModel for DateOnly columns
    • TimeOnlyRangeFilterModel for TimeOnly columns

    Use FilterModelTemplateSelector to assign a dedicated editor template for each model type:

    <dxfui:DateRangeFilterElement FieldName="OrderDate"
           Context="{Binding FilteringContext, ElementName=grid}">
        <dxfui:DateRangeFilterElement.FilterModelTemplateSelector>
            <dxfui:DateRangeFilterModelTemplateSelector
                DateTimeRangeTemplate="{StaticResource DateRangeEditorTemplate}"
                DateOnlyRangeTemplate="{StaticResource DateOnlyEditorTemplate}"
                TimeOnlyRangeTemplate="{StaticResource TimeOnlyEditorTemplate}" />  
        </dxfui:DateRangeFilterElement.FilterModelTemplateSelector>
    </dxfui:DateRangeFilterElement>
    
    See Also