* Require a custom [[SYSCLS_CHILDAREATEMPLATE|Child Area template name]] to work. This customizing will not work applied to the UBIKChildArea.
* Work directly on the Children.Items collection. While filters are active, anything derived from this collection (such as Children.Items.Count or custom datasources like [[XAML_Changes_in_UBIK_WinX_3.5#Filtering_by_expressions|ListCollectionView]] / [[Xamarin_XAML#Content_filtering|sfDataSourceExt]]) will also be affected.
<br><br>
== Usage ==
<tab name="UWP">
<source lang = "xml">
xmlns:controls="using:UBIK.WinX.Controls"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
<controls:ComboBoxExt
x:Name="ComboBox"
PlaceholderText="{Binding Children.Filters[STATUSCOLOR].Value, TargetNullValue='SELECT', FallbackValue='SELECT'}"
DisplayMemberPath="DisplayText"
SelectedValuePath="DisplayText"
* PlaceholderText binds to the same value as your SelectedValueExt to display the current selected item. This is a workaround for a failure of the ComboBox control to correctly display an active selection when the control is rendered.
</tab>
<tab name="Xamarin">
</tab>
<source lang = "xml">
xmlns:ctrlscontrols="clr-namespace:UBIK.CPL.Controls;assembly=UBIK.CPL"
xmlns:classes="clr-namespace:UBIK.CPL.Classes;assembly=UBIK.CPL">
<ctrlscontrols:PickerExt
x:Name="Filter"
ItemsSource="{Binding Properties.AllItems[QUERY].LinkedLevel.Children.Items}"
* ClearPropertyFilters: Clear out all existing filters at the current level before executing the command. This is optional and defaults to false;
* All other parameters: KeyValue pairs used as filter criteria where the Keys are the names of the metaproperties by which you want to filter.
<br>
=== Displaying Results ===
For performance/usability reasons, the result list is not immediately refreshed as one types in the text box. Instead, it only happens after the ReloadChildListCommand is triggered.
This can be done on a dedicated button:
<source lang = "xml">
UWP:
<Button
Content="{Binding Filter, Source={StaticResource UBIKIcons}}"
Style="{StaticResource UBIKSymbolButtonStyle}"
Command="{Binding ReloadChildListCommand}"/>
</source>
<br>
Or in certain cases, can be combined with the filter input to trigger immediately:
<source lang = "xml">
Xamarin:
<Entry.Behaviors>
<behaviors:EventHandlerBehavior EventName="Completed">
<behaviors:InvokeCommandAction Command="{Binding ReloadChildListCommand}" />
</behaviors:EventHandlerBehavior>
</Entry.Behaviors>
</source>
<br>
In more advanced scenarios where a different type of comparison is needed, the example (or more specifically the one KeyValueParameter) can be extended into the following, e.g. comparing whether the specified filter value is equal to the value of the property.
<source lang = "xml">
<classes:KeyValueParameter Key="STA" Value="{Binding Path=SelectedItem.UID, Source={x:Reference Filter}, Converter={StaticResource FilterValueToCriterion}, ConverterParameter=Content[\"\{0\}\"].Value.ToString().Equals(\"\{1\}\")\=\=true}" />
</source>
</source>
<br>
{{Hint|"&quot;" and "\" are used for escaping the special characters in XAML and C# code respectively. "{0}" and "{1}" are placeholders and get replaced by the property name and the filter value. The end expression being executed in this example is <code>Content["PROPERTY_NAME"].Value.ToString().Equals(FILTER_VALUE)==true</code>}}
== UI Customizing ==
=== Update Child List ===
For performance/usability reasons, the result list is not immediately refreshed as one types in the text box. Instead, it only happens after the ReloadChildListCommand is triggered.
=== Filtered Indicator ===
You can also customize UI elements to indicate that filters are active.
<source lang = "xml">
UWP: <Border Background="#8000488E" Visibility="{Binding Children.Filters[SomePropertyName], Converter={StaticResource NullObjOrEmptyStrColConverter}}" />
</source>
<br>
The above border is shown when a filter is active.
Other bindings exist on the Filters collection. Use [[Developer_Mode|Developer Mode]] to see what possibilities are available. Some examples are:
<source lang = "xml">
Children.Filters.Filters.Count
</source>
<br>
<source lang = "xml">
Children.Filters.IsActive
</source>
<br><br>
== Troubleshooting ==
As previously mentioned, only areas with a custom Child Area template name can make use of filters.
When Filters (or Sorting) are applied, a config file is created at '''Local State/Configs''' where the filter data is written and persisted.
{{Attention|Note that during a trial and error phase, filters may be applied that makes a child list fully/partially filtered out of view. }}
This file can be used to inspect how a xaml implementation is being translated into filter criteria.
UWP: The above border is shown when a filter is activeDeleting the file (with the client closed) will remove forget any filters.
[[Category:2.6.1|Property Based Content Filters]]