コード例 #1
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen    = true;
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e) ||
             (e.Key == Key.Escape) ||
             (e.Key == Key.Tab))
         {
             CloseEditor();
             e.Handled = true;
         }
     }
 }
コード例 #2
0
 protected virtual void HandleKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // Calendar will get focus in Calendar_Loaded().
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             ClosePopup(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Enter)
         {
             ClosePopup(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             // Avoid setting the "Value" property when no change has occurred.
             // The original value may not be a local value. Setting
             // it, even with the same value, will override a one-way binding.
             if (!object.Equals(this.Value, _initialValue))
             {
                 this.Value = _initialValue;
             }
             ClosePopup(true);
             e.Handled = true;
         }
     }
 }
コード例 #3
0
 private void OnKeyDown(object sender, KeyEventArgs e)
 {
     if (!IsOpen)
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             IsOpen = true;
             // Calculator will get focus in CalculatorPopup_Opened().
             e.Handled = true;
         }
     }
     else
     {
         if (KeyboardUtilities.IsKeyModifyingPopupState(e))
         {
             CloseCalculatorUpDown(true);
             e.Handled = true;
         }
         else if (e.Key == Key.Escape)
         {
             if (EnterClosesCalculator)
             {
                 if (this.UpdateValueOnEnterKey)
                 {
                     this.TextBox.Text = (_initialValue != null) ? _initialValue.Value.ToString(this.FormatString, this.CultureInfo) : null;
                 }
                 else
                 {
                     this.Value = _initialValue;
                 }
             }
             CloseCalculatorUpDown(true);
             e.Handled = true;
         }
     }
 }