Example #1
0
        //----------------------------------------------------------------------------------------------------------------------------------
        protected void OnPreviewKeyDown(object sender, KeyEventArgs args)
        {
            IntegerTextBox txtBox = sender as IntegerTextBox;

            if (args.Key == Key.Escape)
            {
                args.Handled = true;
                txtBox.Text  = initialValue.ToString();
                Keyboard.ClearFocus();
            }
            else if (args.Key == Key.Enter)
            {
                args.Handled = true;
                //txtBox.Text = lastValidValue.ToString();
                Keyboard.ClearFocus();
            }
        }
Example #2
0
        //----------------------------------------------------------------------------------------------------------------------------------
        void OnTextChanged(object sender, TextChangedEventArgs e)
        {
            IntegerTextBox txtBox = sender as IntegerTextBox;

            if (Text.Trim() == "")
            {
                return;
            }

            if (Command != null)
            {
                BindingExpressionBase expr = BindingOperations.GetBindingExpressionBase(txtBox, CommandParameterProperty);
                if (expr != null)
                {
                    expr.UpdateTarget();
                }

                //Debug.WriteLine($"Send command ({d})");
                if (Command != null && Command.CanExecute(CommandParameter))
                {
                    Command.Execute(CommandParameter);
                }
            }
        }