[Proposal] MathExpressionConverter boolean support #2084
Replies: 4 comments 1 reply
-
For instance, if you wanted to implement the conditional <Label.TextColor>
<MultiBinding Converter="{StaticResource MultiMathExpressionConverter}" ConverterParameter="x0 + x1 + x2 >= 60 ? x3 : x4">
<Binding Mode="OneWay" Path="X0" />
<Binding Mode="OneWay" Path="X1" />
<Binding Mode="OneWay" Path="X2" />
<Binding Source="{x:Static Colors.Green}" />
<Binding Source="{x:Static Colors.Red}" />
</MultiBinding>
</Label.TextColor> Alternatively, you can solve the same problem using <Label
Grid.Row="1"
Grid.Column="7"
Text=">= 60"
TextColor="Green"
VerticalOptions="Center"
VerticalTextAlignment="Center">
<Label.Triggers>
<DataTrigger TargetType="Label">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource MultiMathExpressionConverter}" ConverterParameter="x0 + x1 + x2 >= 60">
<Binding Mode="OneWay" Path="X0" />
<Binding Mode="OneWay" Path="X1" />
<Binding Mode="OneWay" Path="X2" />
</MultiBinding>
</DataTrigger.Binding>
<DataTrigger.Value><x:Boolean>False</x:Boolean></DataTrigger.Value>
<Setter Property="Label.TextColor" Value="Red" />
</DataTrigger>
</Label.Triggers>
</Label> |
Beta Was this translation helpful? Give feedback.
-
I like this idea and it's got some community support I have tagged to be discussed at this months meetup on Thursday 5th September if your able to attend you could add to the conversation. |
Beta Was this translation helpful? Give feedback.
-
@CliffAgius, thanks, I will try to make it. |
Beta Was this translation helpful? Give feedback.
-
This discussion was approved in the September monthly stand-up and approved by the community so has been converted into Issue #2181 for the work to begin. Therefore I am closing this discussion as all work will continue on the Issue for tracking. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a Math Expression Converters #71 refactor enhancement to improve the parser by (1) using a Parsing expression grammar, and (2) to support boolean operations. The grammar is now:
Where
Conditional
,LogicalOr
,LogicalAnd
,Equality
, andCompare
are new.true
andfalse
boolean constants are also new.Sum
,Product
,Power
,Primary
,Number
,Function
, andConstant
are a refactor of what was already supported by the original parser.The implementation can be found:
References:
Beta Was this translation helpful? Give feedback.
All reactions