Jump to: navigation, search

Changes


EvalExpression

172 bytes removed, 11:38, 25 January 2021
/* Simple Calculation */
<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="20032" /> <Editor x:Name="Param1" Width="20043" /> <ctrls:EvalExpression x:Name="Evaluator" Expression="{Binding ElementName=Expression, Path=Text, Source={x:Reference Expression}}"> <ctrls:EvalExpressionParameter Name="P0" Value="{Binding ElementName=Param0, Path=TextWidth, ConverterSource={StaticResource ToTypex:Reference Param0}, ConverterParameter='System.Int32'}" /> <ctrls:EvalExpressionParameter Name="P1" Value="{Binding ElementName=Param1, Path=TextWidth, ConverterSource={StaticResource ToTypex:Reference Param1}, 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 Textbox Editor ''Param0'' contains has a text width of 42 32 and ''Param1'' contains has a text width of 43. If ''Expression'' now contains <code>(P0 + P1) *2</code> then the result would display 170.</tab>
</tabs>