The Label should be visible as long as at least one of the context object's two named properties has a value.</tab>
</tabs>
==== Simple Calculation ====
The following example shows how to use the control with three parameters, where the first two are user input (Textbox ''Param0'' and ''Param1'') and the third one is a property from its DataContext (ViewModel). The evaluated ''Result'' is then bound to a Textblock for output in the UI.
<source lang = "xml">
<StackLayout StackPanel xmlns:ctrls="clr-namespaceusing:UBIK.CPLWinX.Controls;assembly" HorizontalAlignment=UBIK.CPL"Center" Orientation="Vertical"> <Editor TextBox x:Name="Expression" Width="200" /> <Editor TextBox x:Name="Param0" Width="32200"/> <Editor TextBox x:Name="Param1" Width="43200"/> <ctrls:EvalExpression x:Name="Evaluator" Expression="{Binding ElementName=Expression, Path=Text, Source={x:Reference Expression}}"> <ctrls:EvalExpressionParameter Name="P0" Value="{Binding ElementName=Param0, Path=WidthText, SourceConverter={x:Reference Param0StaticResource ToType}, ConverterParameter='System.Int32'}" /> <ctrls:EvalExpressionParameter Name="P1" Value="{Binding ElementName=Param1, Path=WidthText, SourceConverter={x:Reference Param1StaticResource ToType}, ConverterParameter='System.Int32'}" /> <ctrls:EvalExpressionParameter Name="P2" Value="{Binding IsLoggedIn}" />
</ctrls:EvalExpression>
<Label TextBlock Foreground="White" Text="{Binding PathElementName=ResultEvaluator, SourcePath={x:Reference Evaluator}Result}" /></StackLayoutStackPanel>
</source>
Lets assume that the Textbox ''Param0'' contains a text of 42 and ''Param1'' contains a text of 43. If ''Expression'' now contains <code>(P0 + P1) *2</code> then the result would display 170.
<tab name="Xamarin">
HJELP - this doesn't work
The following example shows how to use the control with three parameters, where the first two are user input (Editor ''Param0'' and ''Param1'') and the third one is a property from its DataContext (ViewModel). The evaluated ''Result'' is then bound to an Label for output in the UI.
<source lang = "xml">
<StackLayout xmlns:ctrls="clr-namespace:UBIK.CPL.Controls;assembly=UBIK.CPL">
<Editor x:Name="Expression" Width="200" />
<Editor x:Name="Param0" Width="32200"/> <Editor x:Name="Param1" Width="43200"/> <ctrls:EvalExpression x:Name="Evaluator" Expression="{Binding ElementName=Expression, Path=Text, Source={x:Reference Expression}}"> <ctrls:EvalExpressionParameter Name="P0" Value="{Binding ElementName=Param0, Path=WidthText, SourceConverter={x:Reference Param0StaticResource ToType}, ConverterParameter='System.Int32'}" /> <ctrls:EvalExpressionParameter Name="P1" Value="{Binding ElementName=Param1, Path=WidthText, SourceConverter={x:Reference Param1StaticResource ToType}, ConverterParameter='System.Int32'}" /> <ctrls:EvalExpressionParameter Name="P2" Value="{Binding IsLoggedIn}" /> </ctrls:EvalExpression> <Label Text="{Binding ElementName=Evaluator, Path=Result, Source={x:Reference Evaluator}}" />
</StackLayout>
</source>Lets assume that the Editor Textbox ''Param0'' has contains a width text of 32 42 and ''Param1'' has contains a width text of 43. If ''Expression'' now contains <code>(P0 + P1) *2</code> then the result would display 170.</tab>
</tabs>
[[Category:Client|EvalExpression]][[Category:Pages with broken file links|EvalExpression]][[Category:WinX|EvalExpression]][[Category:Xamarin|EvalExpression]]
==== Setting a calculated Property Value ====
<Grid xmlns:ctrls="clr-namespace:UBIK.CPL.Controls;assembly=UBIK.CPL">
<controls:EvalExpression x:Name="StatusAutomator" Expression="P0 == true ? P00 : (P1 == true ? P10)" Context="{Binding}">
<controls:EvalExpressionParameter Name="P0" Value="{Binding Values[MP_STATUS], Converter={StaticResource EqualityToBool}, ConverterParameter=0}" /> <controls:EvalExpressionParameter Name="P00" Value="State1" /> <controls:EvalExpressionParameter Name="P1" Value="{Binding Values[MP_STATUS], Converter={StaticResource EqualityToBool}, ConverterParameter=10}" /> <controls:EvalExpressionParameter Name="P10" Value="State2" />
</controls:EvalExpression>
<Label
Text="{Binding Path=Result, Source={x:Reference StatusAutomator}}"
FontSize="16"/>
</tabs>
[[Category:Client|EvalExpression]][[Category:Pages with broken file links|EvalExpression]][[Category:WinX|EvalExpression]][[Category:Xamarin|EvalExpression]]
== Parameters ==