MathTransformer Element
Defines a mathematical conversion.
Syntax
<MathTransformer
Absolute="{true | false}"
Add="float"
AddInt="int"
Divide="float"
DivideInt="int"
Mod="float"
ModInt="int"
Multiply="float"
MultiplyInt="int"
Sign="{true | false}"
Subtract="float"
SubtractInt="int"
Type="TypeCode enumeration"
/>
Attributes
Absolute
Indicates whether the result is an absolute value.
Add
Specifies a float value to add.
AddInt
Specifies an int value to add.
Divide
Specifies a float value to divide by.
DivideInt
Specifies an int value to divide by.
Mod
Specifies a float value for the modulo operation.
ModInt
Specifies an int value for the modulo operation.
Multiply
Specifies a float value to multiply by.
MultiplyInt
Specifies an int value to multiply by.
Sign
Indicates whether to include the sign.
Subtract
Specifies a float value to subtract.
SubtractInt
Specifies an int value to subtract.
Type
Sets the return type. This value must be a member of the TypeCode enumeration. For more information, see TypeCode Enumeration on the MSDN web site.
Remarks
The MathTransformer element allows you to manipulate numeric values by applying math operators (Add, Subtract, Multiply, Divide, Modulo, Absolute, and Sign). The MathTransformer element can also apply a numeric type conversion to the end result. There are "int" versions of these properties to support integer operations.
MathTransformer applies the operators you specify in the following order:
- Multiplication
- Division
- Addition
- Subtraction
- Modulus
- Absolute
- Sign
- Type
The target of the MathTransformer must accept the same type as the original value or the converted type if a conversion was specified.
You cannot perform one conversion after another on the same variable in a chain. To perform multiple conversions, you can transform the value to an intermediate local and then bind that value to your target using another transformer, or use multiple actions on the same variable using a rule.
Example Code
<Mcml
xmlns="https://schemas.microsoft.com/2006/mcml"
xmlns:cor="assembly://MSCorLib/System">
<UI Name="MathTransformer">
<Locals>
<cor:Int32 Name="Value" Int32="6" />
</Locals>
<Rules>
<!-- This performs the following operation: -->
<!-- (6 * 4) / 8 = 3 -->
<!-- Note that multiplication precedes division, regardless of the order you specify them. -->
<Binding Source="[Value]" Target="[Label.MaximumLines]">
<Transformer>
<MathTransformer DivideInt="8" MultiplyInt="4" />
</Transformer>
</Binding>
</Rules>
<Content>
<ColorFill Content="Firebrick" MaximumSize="200,200">
<Children>
<Text Name="Label" Content="Only three lines worth of this text will be displayed."
Color="White" Font="Verdana, 20" MaximumLines="[Value]" WordWrap="true"/>
</Children>
</ColorFill>
</Content>
</UI>
</Mcml>
Requirements
Platform: Windows Vista Ultimate, Windows Vista Home Premium, and later
See Also