From 6cacb81d3f0c31475a3bd5bad7422772c552a0b6 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Tue, 29 Mar 2011 14:36:54 +0000 Subject: [PATCH] CalculatorUpDown: fixed issue with not being able to tab out of control. Added EnterClosesCalculator property when set to true, whenever the enter button is pressed it will update the value and then close the calculator popup. EnterClosesCalculator="false" by default. --- .../Implementation/CalculatorUpDown.cs | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Main/Source/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs b/Main/Source/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs index 81aab081..60a69eb5 100644 --- a/Main/Source/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs +++ b/Main/Source/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs @@ -1,16 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using System.Windows.Controls.Primitives; namespace Microsoft.Windows.Controls @@ -26,6 +16,17 @@ namespace Microsoft.Windows.Controls #region Properties + #region EnterClosesCalculator + + public static readonly DependencyProperty EnterClosesCalculatorProperty = DependencyProperty.Register("EnterClosesCalculator", typeof(bool), typeof(CalculatorUpDown), new UIPropertyMetadata(false)); + public bool EnterClosesCalculator + { + get { return (bool)GetValue(EnterClosesCalculatorProperty); } + set { SetValue(EnterClosesCalculatorProperty, value); } + } + + #endregion //EnterClosesCalculator + #region IsOpen public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(CalculatorUpDown), new UIPropertyMetadata(false, OnIsOpenChanged)); @@ -44,7 +45,7 @@ namespace Microsoft.Windows.Controls protected virtual void OnIsOpenChanged(bool oldValue, bool newValue) { - + } #endregion //IsOpen @@ -90,13 +91,23 @@ namespace Microsoft.Windows.Controls { switch (e.Key) { + case Key.Enter: + { + if (EnterClosesCalculator && IsOpen) + CloseCalculatorUpDown(); + break; + } case Key.Escape: - case Key.Tab: { CloseCalculatorUpDown(); e.Handled = true; break; } + case Key.Tab: + { + CloseCalculatorUpDown(); + break; + } } }