<br>
[[Category:Client|Custom Filtering]][[Category:Filtering|Custom Filtering]][[Category:Styling|Custom Filtering]][[Category:WinX|Custom Filtering]][[Category:XAML|Implement Custom Filtering]][[Category:Xamarin|Custom Filtering]]
== Multiple Dynamic (User Inputs) Criteria ==
<br>
[[Category:Client|Custom Filtering]][[Category:Filtering|Custom Filtering]][[Category:Styling|Custom Filtering]][[Category:WinX|Custom Filtering]][[Category:XAML|Implement Custom Filtering]][[Category:Xamarin|Custom Filtering]]
== Combining Dynamic (User Inputs) and Static (Predefined) Criteria ==
<br>
[[Category:Client|Custom Filtering]]
[[Category:Filtering|Custom Filtering]]
[[Category:Styling|Custom Filtering]]
[[Category:WinX|Custom Filtering]]
[[Category:XAML|Implement Custom Filtering]]
[[Category:Xamarin|Custom Filtering]]
{{UnderConstructionStart}}
{{UnderConstructionEnd}}
[[Category:Client|Custom Filtering]][[Category:Filtering|Custom Filtering]][[Category:Styling|Custom Filtering]][[Category:WinX|Custom Filtering]][[Category:XAML|Implement Custom Filtering]][[Category:Xamarin|Custom Filtering]]
== Adjustments ==
"{Binding Path=Count, Source={StaticResource FilterView}}"
</source>
== Persisting Filter Values ==
{{UnderConstructionStart}}
One of the drawbacks of this method of filtering, when compared to [[Property_Based_Content_Filters]], for example, is the inability to remember user inputs when they navigate away from the page. This section describes how to implement a limited solution to this issue, the limitation being that values can currently only be persisted during the 'session', and will be closed if the user closes the client.
This solution involves use of the StoreProfileParametersCommand to save a simple key-value pair (a simple list of items made up of a name and a value), which can then be read using the syntax: StoredProfileParameters[key]. The StoreProfileParameterCommand accepts a CommandParameter with the format 'key=value', where 'key' represents the name of the key-value pair that can be used to reference it later (in the case below, 'name'), and 'value' represents what string should be returned by referencing it (in this case, the Text attribute of the text field control).
When a user completes their input, we use the StoreProfileParametersCommand to create or update a key-value pair associated with a particular filter, instead of passively reading the value from the input as was done previously.
Furthermore, the associated StoredProfileParameter is fed back to the input control, so that it's value will be displayed if any is set, otherwise the input control will be reset when next loading the page, whereas the StoredProfileParameter will be persisted, leading to a mismatch between the UI and filtering state.
<tabs>
<tab name="UWP">
<source lang = "xml">
<TextBox x:Name="NameInput" PlaceholderText="{Binding StoredProfileParameter[name]}">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="LostFocus">
<core:InvokeCommandAction Command="{Binding StoreProfileParameterCommand}" CommandParameter="{Binding Text, ElementName=DateInput, Converter={StaticResource StringFormatConverter}, ConverterParameter='name={0}'}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</TextBox>
</source>
</tab>
<tab name="Xamarin">
<source lang = "xml">
<Entry x:Name="NameInput" Text="{Binding StoredProfileParameters[name]}">
<Entry.Behaviors>
<behaviors:EventHandlerBehavior EventName="Completed">
<behaviors:InvokeCommandAction Command="{Binding StoreProfileParameterCommand}" CommandParameter="{Binding Path=Text, Source={x:Reference NameInput}, StringFormat='name={0}'}" />
</behaviors:EventHandlerBehavior>
</Entry.Behaviors>
</Entry>
</source>
</tab>
{{Hint|StringFormatConverter/StringFormat is used to format the key-value pair as required by the StoreProfileParameterCommand. The key is hardcoded into the formatted string as, for example <noWiki>'name='</noWiki>. The dynamic value, in this case whatever is inputted in the text field when the edit is completed, replaces the <noWiki>{0}</noWiki> tag when the binding is evaluated (ie. when the command is executed).
</tabs>
In this implementation, the EvalExpression also needs to be adapted to check whether a particular filter value exists within the StoredProfileParameters list, instead of simply whether the associated input control has a value or selection:
<tabs>
<tab name="UWP">
<source lang = "xml">
<controls:EvalExpression x:Name="Name_FilterExpression" Context="{Binding}" Expression="(INPUT==null||INPUT=="") ? "true==true" : EXP">
<controls:EvalExpressionParameter Name="EXP" Value="{Binding StoredProfileParameters[name], Converter={StaticResource StringFormatConverter}, ConverterParameter='Item.PropertyItems["NAME"].ToString("yyyy/MM/dd").Equals("{0}")==true'}" />
<controls:EvalExpressionParameter Name="INPUT" Value="{Binding StoredProfileParameters[name]}" />
</controls:EvalExpression>
</source>
</tab>
<tab name="Xamarin">
<source lang = "xml">
<controls:EvalExpression x:Key="Name_FilterExpression" Expression="(INPUT==null||INPUT=="") ? "true==true" : EXP " Context="{Binding}">
<controls:EvalExpressionParameter Name="EXP" Value="{Binding StoredProfileParameters[name], Converter={StaticResource StringFormat}, ConverterParameter='Item.PropertyItems["NAME"].Value.ToString("yyyy/MM/dd").Contains("{0}")==true'}" />
<controls:EvalExpressionParameter Name="INPUT" Value="{Binding StoredProfileParameters[name]}" />
</controls:EvalExpression>
</source>
</tab>
</tabs>
{{UnderConstructionEnd}}