Changes
/* Selection */ Separated String and GUID examples, expanded ItemsSource
=== 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>
</tab>
<tab name="Xamarin">
<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>
* 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 ===
