diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 2a0caf13e..ccb66d009 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -21,7 +21,7 @@ namespace Tango.Touch.Controls { private TextBox _text_box; private bool _prevent_text_change; - private TextBlock _text_block; + private FastTextBlock _text_block; private double _lastValue; Regex regex_integer = new Regex(@"^-?[0-9]\d*(\d+)?$"); Regex regex_double = new Regex(@"^-?[0-9]\d*(\.\d+)?$"); @@ -109,12 +109,22 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty AutoCalculateJogStepProperty = DependencyProperty.Register("AutoCalculateJogStep", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(true)); + public bool UpdateBindingOnlyWhenFocused + { + get { return (bool)GetValue(UpdateBindingOnlyWhenFocusedProperty); } + set { SetValue(UpdateBindingOnlyWhenFocusedProperty, value); } + } + public static readonly DependencyProperty UpdateBindingOnlyWhenFocusedProperty = + DependencyProperty.Register("UpdateBindingOnlyWhenFocused", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(false)); + + + public override void OnApplyTemplate() { base.OnApplyTemplate(); _text_box = GetTemplateChild("PART_TextBox") as TextBox; - _text_block = GetTemplateChild("PART_TextDisplay") as TextBlock; + _text_block = GetTemplateChild("PART_TextDisplay") as FastTextBlock; _text_box.PreviewTextInput += _text_box_PreviewTextInput; _text_box.PreviewKeyDown += _text_box_PreviewKeyDown; _text_box.LostFocus += _text_box_LostFocus; @@ -222,8 +232,11 @@ namespace Tango.Touch.Controls _lastValue = Value; - DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); - RaiseEvent(args); + if (!UpdateBindingOnlyWhenFocused || (_text_box != null && _text_box.IsKeyboardFocused)) + { + DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); + RaiseEvent(args); + } } } |
