Good afternoon. My name is Eugene. First of all I bag your pardon for my poor English. I have the following question. In WPF-application main window I have a TextBox and in XAML markup I describe it as the follow:
<TextBox Name="tbxRange" Grid.Row="1" Grid.Column="3" TextAlignment="Center"
Text="{Binding Path=CurCompassRange.Range, UpdateSourceTrigger=PropertyChanged,
Mode=OneWayToSource, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
In this TextBox I print a floating point number value. The contents of the Text property can be changed many times pending program execution. In the MainWindow class I have the following members as a fields:
private static Double topMargin = 0;
private static Double bottomMargin = 0;
private static Double initialValue;
The value to "initialValue" assigned once when application begins to run. I'm in need of the following. When I print a new number in TextBox its value first must be subtracted from "initialValue" (the value of "initialValue" itself doesn't change) and the result of subtraction must be stored in "bottomMargin" and secondly the value of printed number must be added to "initialValue" and the result of addition must be stored in "topMargin". I can change the contents of Text property of TextBox many times pending program execution. My question is the following. Can I write in XAML markup some triggers which can do above mentioned subtraction and addition each time the value of TextBox Text property changes? Of course I know that I can try to write (on C#) TextBox TextInput event handler to do these operations and do subtraction and addition in its body but to use triggers in XAML markup seems me more gracefuly. I'll be very appreciative to your help. I'm not very strong in WPF. Please help me.