=== Selection ===
Selection is trickier to achieve than direct input, as often a metaproperty's actual value might differ from the text that is displayed for that value. Just think of integer-based statuses, or GUID properties.
==== List Properties ====
The below examples use a custom ComboBox/Picker control to display a list of items. Because the filter comparison is based on the DisplayValue of the metaproperty, the DisplayText of the selected object is then passed on as a part of the command parameter and later used as a filter criterion to filter for objects that have the same the string.
<tabs>
<tab name="UWP">
SelectedValue="{Binding Children.Filters[STATUSCOLOR].Value}"
SelectedValueExt="{Binding Children.Filters[STATUSCOLOR].Value}"
ItemsSource="{Binding Children.Items[10].Properties.AllItems[STATUSCOLOR].MetaProperty.SelectiveList, Converter={StaticResource SelectiveListToItemsConverter}}">
<interactivity:Interaction.Behaviors>
</controls:ComboBoxExt>
</source>
Note that several elements are required for this customization to work:
* SelectedValuePath informs the control of which property should be supplied to the command as a filter criteria. This should match what is supplied in your KeyValueParameter.
* DisplayMemberPath informs the control of which property should be visualized as the displaytext of your selection.
* 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:controls="clr-namespace:UBIK.CPL.Controls;assembly=UBIK.CPL"
<controls:PickerExt
x:Name="Filter"
ItemsSource="{Binding Children.Items[0].Properties.AllItems[QUERYSTATUSCOLOR].LinkedLevelMetaProperty.Children.ItemsSelectiveList, Converter={StaticResource SelectiveListToItemsConverter}}" ItemDisplayBinding="{Binding HeaderDisplayText}"
SelectionChangedCommand="{Binding Children.UpdatePropertyFiltersCommand}"
SelectedValuePath="UIDDisplayText"
SelectedValue="{Binding Children.Filters[STA].Value, Mode=OneWay}">
<ctrlscontrols:PickerExt.SelectionChangedCommandParameter>
<classes:KeyValueList>
<classes:KeyValueParameter Key="ClearPropertyFilters" Value="false" />
<classes:KeyValueParameter Key="STA" Value="{Binding Path=SelectedItem.UIDDisplayText, Source={x:Reference Filter}}" />
</classes:KeyValueList>
</ctrlscontrols:PickerExt.SelectionChangedCommandParameter></ctrlscontrols:PickerExt>
</source>
</tab>
</tabs>
The example above uses a custom ComboBox/Picker Note that several elements are required for this customization to work:* '''SelectedValuePath''' informs the control of which property should be supplied to display the command as a list of itemsfilter criteria. The chosen aspect of This should match what is supplied in your KeyValueParameter.* '''DisplayMemberPath'''/'''ItemDisplayBinding''' informs the control of which property should be visualized as the selected object displaytext of your selection. Note that this is then passed a binding on Xamarin only.* In UWP: '''PlaceholderText''' binds to the same value as your SelectedValueExt to display the current selected item. This is a workaround for a part failure of the command parameter and later used as ComboBox control to correctly display an active selection when the control is rendered. In Xamarin, a filter criterion secondary label is required to filter for objects that have display a placeholder text when the same the stringPicker's SelectedIndex is null.
This Furthermore, this approach makes use of the '''Children.UpdatePropertyFiltersCommand''', which uses the following parameters:
* 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>
===== ItemsSource =====
{{Attention| The '''ItemsSource''' in the above example is a way to populate the selection list dynamically by taking the MetaProperty.SelectiveList items of the STATUSCOLOR property that we are filtering, taken from the first child in the list. This selection list will therefore become empty if all items are filtered out of the Children collection.}}
For simple string properties, it is also possible to hardcode the options in the selection list as follows:
<tabs>
<tab name="UWP">
<source lang = "xml">
<x:String>Green</x:String>
<x:String>White</x:String>
<x:String>Yellow</x:String>
</source>
Simply add the strings as content of the controls:ComboBoxExt.
</tab>
<tab name="Xamarin">
<source lang = "xml">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Green</x:String>
<x:String>White</x:String>
<x:String>Yellow</x:String>
</x:Array>
</Picker.ItemsSource>
</source>
</tab>
</tabs>
<br>
Note that you will then need to remove references to the DisplayText, as the x:String value becomes the value used to filter.
==== GUID Properties ====
The above controls:ComboBoxExt and controls:PickerExt examples can be converted to filter GUID values as follows:
<source lang = "xml">
Xamarin:
<controls:PickerExt
x:Name="Plant_Filter"
ItemsSource="{Binding Properties.AllItems[LK_PLANT_QUERY].LinkedLevel.Children.Items}"
ItemDisplayBinding="{Binding Header}"
SelectionChangedCommand="{Binding Children.UpdatePropertyFiltersCommand}"
SelectedValuePath="UID"
SelectedValue="{Binding Children.Filters[LK_PLANT_SECTION].Value, Mode=OneWay}">
<controls:PickerExt.SelectionChangedCommandParameter>
<classes:KeyValueList>
<classes:KeyValueParameter Key="ClearPropertyFilters" Value="false" />
<classes:KeyValueParameter Key="LK_PLANT_SECTION" Value="{Binding Path=SelectedItem.UID, Source={x:Reference Plant_Filter}, Converter={StaticResource FilterValueToCriterion}, ConverterParameter=Content[\"\{0\}\"].Value.ToString().Equals(\"\{1\}\")\=\=true}" />
</classes:KeyValueList>
</controls:PickerExt.SelectionChangedCommandParameter>
</controls:PickerExt>
</source>
<br>
Note that in this example, a Properties.AllItems[LK_PLANT_QUERY] is added to the Content object to provide the list of items displayed by the Picker, as a workaround to the Children.Items[0] approach.
[[Category:2.6.1|Property Based Content Filters]]
[[Category:Version 1.2|Property Based Content Filters]]
[[Category:WinX|Property Based Content Filters]]
[[Category:Xamarin|Property Based Content Filters]]
=== Displaying Results ===