Version

Properties List Filtering (xamPropertyGrid)

Topic Overview

Purpose

This topic explains how to configure the filtering of the control’s properties list.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic explains the features supported by the control from developer perspective.

This topic provides an overview of the visual elements of the control.

Filtering Introduction

Filtering summary

The xamPropertyGrid allows the user to enter a filter value in the text box located in the filtering area at the top of the control. This filter is used as a "contains" filter when evaluating properties for inclusion in the displayed property list. The pipe symbol (i.e., "|") can also be used to specify multiple filter criteria which are then combined using an "Or" operator.

The control’s FilterText property is bound by default to the filter area textbox so it always reflects the current value typed by the end user. In addition you can programmatically add custom filters (based on the ICondition interface) via the control’s ItemFilters property which are combined using an "and" operator with the filter criteria specified by the user.

To create custom filters you can use your own classes which implements the ICondition interface or use one of the classes supplied xamPropertyGrid assembly – PropertyGridComparisonCondition, PropertyGridComplementCondition and PropertyGridConditionGroup. Each of these expose an OperandSource property of type PropertyGridFilterOperandSource which lets you specify the PropertyGridPropertyItem value that should be used when evaluating whether a particular item satisfies.

Code Examples Summary

Code examples summary chart

The following table lists the code examples included in this topic.

Example Description

The following example shows how to add a filter which will result showing of properties which name contains either "Brush" or "Color".

The following example shows how to add a filter which will result showing of properties which are from the category "Appearance" and their name contains "Visibility".

Code Example: Filter Properties by Property Name

Description

The following example shows how to add a filter which will result showing of properties which name contains either "Brush" or "Color".

Code

Following is the code that implements this example.

In XAML:

<ig:XamPropertyGrid>
  <ig:XamPropertyGrid.ItemFilters>
    <ig:PropertyGridConditionGroup LogicalOperator="Or">
      <ig:PropertyGridComparisonCondition Operator="Contains" Value="Brush" />
      <ig:PropertyGridComparisonCondition Operator="Contains" Value="Color" />
    </ig:PropertyGridConditionGroup>
  </ig:XamPropertyGrid.ItemFilters>
</ig:XamPropertyGrid>
Note
Note

The OperandSource property is omitted because its default value is PropertyName.

Note
Note

Creating item filters as described above would produce the same result as the user typing "Brush | Color" in the filter textbox.

Code Example: Filter Properties by Property Name and Category

Description

The following example shows how to add a filter which will result showing of properties which are from the category "Appearance" and their name contains "Visibility".

Code

Following is the code that implements this example.

In XAML:

<ig:XamPropertyGrid>
  <ig:XamPropertyGrid.ItemFilters>
    <ig:PropertyGridConditionGroup LogicalOperator="And">
      <ig:PropertyGridComparisonCondition OperandSource="CategoryName"
        Operator="Equals" Value="Appearance" />
      <ig:PropertyGridComparisonCondition OperandSource="PropertyName"
        Operator="Contains" Value="Visibility" />
    </ig:PropertyGridConditionGroup>
  </ig:XamPropertyGrid.ItemFilters>
</ig:XamPropertyGrid>
Note
Note

It is not possible for the end user to create the item filters as described above using the filter textbox. There are 2 reasons for this:

  • The filter criteria is combined using an "And" operator (the filter textbox uses an "Or" operator when combining multiple criteria).

  • The filter criteria is filtering based on "CategoryName" (the filter textbox only filters based on "PropertyName").

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to configure some general control options.

This topic explains how to customize the editors used for editing the properties’ values.

This topic explains how to provide logic for custom sorting of the properties list.

This topic explains how create custom logic for assigning editing template on an editor definition.