The form CustomersView displays the results of a query to Customers table in a TreeView control.

TreeView has two levels of grouping (by countries and cities) and the form of quick filtering. The result is returned as enumeration of CountryCustomersTreeItem elements , having the embedded collections:

Pic9

How use.

To implement a quick filter create a custom control and include it in the view:

CustomersView.xaml
...
    <bsFilter:FilterControl Key="Country"
                          ParentCollection="{TemplateBinding ItemsSource}">
    <bsFilter:FilterControl.FilterInitializersManager>
        <bsFilter:FilterInitializersManager>
            <vm:CustomersTreeFilterInitializer />
        </bsFilter:FilterInitializersManager>
    </bsFilter:FilterControl.FilterInitializersManager>
</bsFilter:FilterControl>
...

How work.

FilterControl, included in the view, serves to filter both in the original collection, returned by the query, and nested collections (returned by CountryCustomersTreeItem.Cities and CityCustomersTreeItem.Customers). To control the initial and nested collections created three classes of filters – CountriesTreeFilter, CitiesTreeFilter и CustomersTreeFilter – one for each level of filtering. The model representation of the quick filter is an instance of CountriesTreeFilter. When connecting the collection, CountriesTreeFilter enumerates instances of the CountryCustomersTreeItem and produces filters for each CityCustomersTreeItem, transferred in the property Cities. References to the generated filters are saved for transmission filter conditions and use in the filter function IsMatch . Similar work was done on the instance level filter CitiesTreeFilter.

How look.

Pic10

Finally.

Last edited Nov 9, 2013 at 6:17 AM by Mishkin, version 7