windowsforms-115924-common-features-filtering-ui-context-filtering-ui-context-designer.md
The Filtering Model Configuration Wizard allows you to build and fine-tune your filtering Models and generated editors. To start this wizard, invoke the component’s smart-tag and select the corresponding link, as shown below.
The first wizard page lists all classes that can be used as filtering Models.
You can choose the existing Model or select “None”. The latter option is described below; for now, select an existing Model and click “Next” to proceed.
The second wizard page shows a list of public properties declared within a class you have selected previously. Each item in this list displays a check box, which you can use to specify whether or not the component should generate an editor for this specific property.
Editors on the right side of this wizard page affect the filtering editor that will be generated for the currently selected property. You can hover over each menu to view a detailed description for it.
The Filtering Attributes topic demonstrates how to apply same changes in code by declaring attributes before filtering properties. The wizard does the same, but its generated attributes are stored within an external custom attributes collection. A filtering Model remains intact. If a filtering Model contains same attributes, they will have a lower priority compared to those from the custom collection.
Along with modifying existing filtering Model properties and editors they will produce, the Filtering Model Configuration Wizard can filter data against custom data fields. In other words, you can filter data against properties that are not defined within a filter Model your Filtering UI Context component uses. To do so, click the “Add Custom Filter” on the wizard’s second page. When you select a custom property which appears in the list, two additional options will be enabled in addition to those caption, editor type and description options mentioned before.
Adding custom filters will be your only option if you select ‘None’ on the first wizard page. This allows you to use the Filtering UI Context component without an external Model at all. Instead, the wizard writes all of your custom filtering attributes directly to your form’s designer class like in the sample below.
this.filteringUIContext1.CustomMetricAttributes.AddRange(new DevExpress.Utils.Filtering.CustomMetricsAttributeExpression[] {
new DevExpress.Utils.Filtering.CustomMetricsAttributeExpression("Model", typeof(string), new DevExpress.Utils.Filtering.IAttributeInfo[] {
((DevExpress.Utils.Filtering.IAttributeInfo)(new DevExpress.Utils.Filtering.FilterLookupAttributeInfo(DevExpress.Utils.Filtering.LookupUIEditorType.List, null, null, null)))}),
new DevExpress.Utils.Filtering.CustomMetricsAttributeExpression("Price", typeof(int), new DevExpress.Utils.Filtering.IAttributeInfo[] {
((DevExpress.Utils.Filtering.IAttributeInfo)(new DevExpress.Utils.Filtering.FilterRangeAttributeInfo(DevExpress.Utils.Filtering.RangeUIEditorType.Range, null, null, null, null)))}),
new DevExpress.Utils.Filtering.CustomMetricsAttributeExpression("InStock", typeof(bool), new DevExpress.Utils.Filtering.IAttributeInfo[] {
((DevExpress.Utils.Filtering.IAttributeInfo)(new DevExpress.Utils.Filtering.FilterBooleanChoiceAttributeInfo(DevExpress.Utils.Filtering.BooleanUIEditorType.Check, null, null)))})});
Me.filteringUIContext1.CustomMetricAttributes.AddRange(New DevExpress.Utils.Filtering.CustomMetricsAttributeExpression() {
New DevExpress.Utils.Filtering.CustomMetricsAttributeExpression("Model", GetType(String), New DevExpress.Utils.Filtering.IAttributeInfo(Of System.Attribute)() {
(CType(New DevExpress.Utils.Filtering.FilterLookupAttributeInfo(DevExpress.Utils.Filtering.LookupUIEditorType.List, Nothing, Nothing, Nothing), DevExpress.Utils.Filtering.IAttributeInfo(Of System.Attribute)))}),
New DevExpress.Utils.Filtering.CustomMetricsAttributeExpression("Price", GetType(Integer), New DevExpress.Utils.Filtering.IAttributeInfo(Of System.Attribute)() {
(CType(New DevExpress.Utils.Filtering.FilterRangeAttributeInfo(DevExpress.Utils.Filtering.RangeUIEditorType.Range, Nothing, Nothing, Nothing, Nothing), DevExpress.Utils.Filtering.IAttributeInfo(Of System.Attribute)))}),
New DevExpress.Utils.Filtering.CustomMetricsAttributeExpression("InStock", GetType(Boolean), New DevExpress.Utils.Filtering.IAttributeInfo(Of System.Attribute)() {
(CType(New DevExpress.Utils.Filtering.FilterBooleanChoiceAttributeInfo(DevExpress.Utils.Filtering.BooleanUIEditorType.Check, Nothing, Nothing), DevExpress.Utils.Filtering.IAttributeInfo(Of System.Attribute)))})})
If needed, these attributes can later be manually modified in code or you can simply re-run the wizard to re-configure your custom filters.