NoesisGUI
 

🔹 MathConverter Class

namespace NoesisApp

Evaluates a mathematical expression provided as a string.

MathConverter can be used as both a standard IValueConverter and an IMultiValueConverter. It supports standard arithmetic operators (+, -, *, /, %), parentheses, and common math functions (min, max, floor, round, ceil, sin, cos, pow, abs).

  • Variables from bindings are referenced using their index inside brackets (e.g., {0}, {1}).
  • The ConverterParameter is referenced using an underscore inside brackets: {_}.
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">

  <Grid.Resources>
    <noesis:MathConverter x:Key="Math" />
  </Grid.Resources>

  <Canvas>
    <Rectangle Width="100" Height="50" Fill="Red"
      Canvas.Left="{Binding ActualWidth, ElementName=Root,
        Converter={StaticResource Math}, ConverterParameter=2,
        Expression='{0} / {_}'}"/>
  </Canvas>

  <TextBlock>
    <TextBlock.Text>
      <MultiBinding Converter="{StaticResource Math}" ConverterParameter="0.5"
          Expression="pow(pow({0}, 2) + pow({1}, 2), {_})">
        <Binding Path="SideA" />
        <Binding Path="SideB" />
      </MultiBinding>
    </TextBlock.Text>
  </TextBlock>
</Grid>

Inheritance Hierarchy

MathConverter

📚 Class Hierarchy Index

Properties

MathConverter has no properties

Attached Properties

MathConverter has no attached properties

Methods

From BaseValueConverter

Name Description
 TryConvert(BaseComponent*, const Type*, BaseComponent*, Ptr<BaseComponent>&)

The data binding engine calls this method when it propagates a value from the binding source to the binding target.

Return DependencyProperty.UnsetValue to indicate that the converter produced no value and that the fallback (if available) or default value should be used instead.

Return Binding.DoNothing to indicate that the binding should not transfer the value or use the fallback or default value.

 TryConvertBack(BaseComponent*, const Type*, BaseComponent*, Ptr<BaseComponent>&)

The data binding engine calls this method when it propagates a value from the binding target to the binding source.

Return Binding.DoNothing to indicate that no value should be set on the source property.

Return DependencyProperty.UnsetValue to indicate that the converter is unable to provide a value for the source property, and no value will be set to it.

Events

MathConverter has no events

 
© 2017 Noesis Technologies