Browse Source

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.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
e1c01ca2f3
  1. 35
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs

35
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;
}
}
}

Loading…
Cancel
Save