void ClassBreaksNumericUpDown_ValueChanging(object sender, RoutedPropertyChangingEventArgs<double> e)
 {
     if (e.NewValue < 2) // don't let users have less than 2 class breaks
     {
         e.Cancel = true;
         return;
     }            
 }
 public void Instantiate()
 {
     RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(null, true, false, true);
     Assert.IsTrue(args.IsCancelable);
 }
示例#3
0
 private void point_start_autocompletebox_DropDownClosing(object sender, RoutedPropertyChangingEventArgs<bool> e)
 {
     this.Focus();
 }
示例#4
0
 void autoCompleteBox_DropDownOpening(object sender, RoutedPropertyChangingEventArgs<bool> e)
 {
     if (!_autocompleteFocus)
         e.Cancel = true;
 }
        protected virtual void OnValueChanging(RoutedPropertyChangingEventArgs<DateTime?> e)
        {
            // change is from value itself.
            bool success = _timeCoercionHelper.CoerceValue(e.OldValue, e.NewValue);

            if (success)
            {
                e.InCoercion = false;
                e.NewValue = Value;
                RoutedPropertyChangingEventHandler<DateTime?> handler = ValueChanging;
                if (handler != null)
                {
                    handler(this, e);
                }
            }
            else
            {
                e.InCoercion = true;
            }
        }
        /// <summary>
        /// ValueProperty property changed handler.
        /// </summary>
        /// <param name="d">UpDownBase whose Value changed.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TimePickerPopup source = (TimePickerPopup)d;

            // Ignore the change if requested
            if (source._ignoreValueChange)
            {
                // we do want to raise the event, but won't react to anything.
                source.OnValueChanged(new RoutedPropertyChangedEventArgs<DateTime?>(e.OldValue as DateTime?, e.NewValue as DateTime?));
                return;
            }

            DateTime? oldValue = (DateTime?)e.OldValue;
            DateTime? newValue = (DateTime?)e.NewValue;

            // simulate pre and post events
            // The Value has already been changed when this function is called. 
            // So if user's chaning event handler check Value, it will be the changed value.
            // This is confusing, because we are simulating pre event on the platform that doesn't natively support it.
            RoutedPropertyChangingEventArgs<DateTime?> changingArgs = new RoutedPropertyChangingEventArgs<DateTime?>(e.Property, oldValue, newValue, true);
            source.OnValueChanging(changingArgs);

            // workaround the class hierarchy for value coercion
            if (changingArgs.InCoercion)
            {
            }
            else if (!changingArgs.Cancel)
            {
                newValue = changingArgs.NewValue;
                RoutedPropertyChangedEventArgs<DateTime?> changedArgs = new RoutedPropertyChangedEventArgs<DateTime?>(oldValue, newValue);
                source.OnValueChanged(changedArgs);

                TimePickerPopupAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(source) as TimePickerPopupAutomationPeer;
                if (peer != null)
                {
                    peer.RaiseValueAutomationEvent(oldValue, newValue);
                }
            }
            else
            {
                // revert back to old value if an event handler canceled the changing event.
                source._ignoreValueChange = true;
                source.Value = oldValue;
                source._ignoreValueChange = false;
            }
        }
 /// <summary>
 /// Performs test actions for the OnDropDownClosing method.
 /// </summary>
 /// <param name="e">Event arguments.</param>
 protected override void OnDropDownClosing(RoutedPropertyChangingEventArgs<bool> e)
 {
     DropDownClosingActions.DoPreTest(e);
     base.OnDropDownClosing(e);
     DropDownClosingActions.DoTest(e);
 }
示例#8
0
        /// <summary>
        /// Begin opening the drop down by firing cancelable events, opening the
        /// drop-down or reverting, depending on the event argument values.
        /// </summary>
        /// <param name="oldValue">The original value, if needed for a revert.</param>
        private void OpeningDropDown(bool oldValue)
        {
#if SILVERLIGHT
            RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, true, true);
#else
            RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, true, true, DropDownOpeningEvent);
#endif
            // Opening
            OnDropDownOpening(args);

            if (args.Cancel)
            {
                _ignorePropertyChange = true;
                SetValue(IsDropDownOpenProperty, oldValue);
            }
            else
            {
                RaiseExpandCollapseAutomationEvent(oldValue, true);
                OpenDropDown(oldValue, true);
            }

            UpdateVisualState(true);
        }
示例#9
0
        /// <summary>
        /// IsDropDownOpenProperty property changed handler.
        /// </summary>
        /// <param name="d">Picker that changed its IsDropDownOpen.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnIsDropDownOpenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Picker source = (Picker)d;

            // Ignore the change if requested
            if (source._ignorePropertyChange)
            {
                source._ignorePropertyChange = false;
                return;
            }

            bool oldValue = (bool)e.OldValue;
            bool newValue = (bool)e.NewValue;
            bool delayedClosingVisual = source._popupClosedVisualState;
            RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(e.Property, oldValue, newValue, true);

            PickerAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(source) as PickerAutomationPeer;
            if (peer != null)
            {
                peer.RaiseExpandCollapseAutomationEvent(oldValue, newValue);
            }

            if (newValue)
            {
                // Opening
                source.OnDropDownOpening(args);

                // Opened
                if (!args.Cancel)
                {
                    source.OpenDropDown(oldValue, newValue);
                }
            }
            else
            {
                // Closing
                source.OnDropDownClosing(args);

                // Immediately close the drop down window:
                // When a popup closed visual state is present, the code path is 
                // slightly different and the actual call to CloseDropDown will 
                // be called only after the visual state's transition is done
                if (!args.Cancel && !delayedClosingVisual)
                {
                    source.CloseDropDown(oldValue, newValue);
                }
            }

            // If canceled, revert the value change
            if (args.Cancel)
            {
                // source._ignorePropertyChange = true;
                source.SetValue(e.Property, oldValue);
            }

            // Closing call when visual states are in use
            if (delayedClosingVisual)
            {
                source.UpdateVisualState(true);
            }
        }
示例#10
0
 /// <summary>
 /// Raises the
 /// <see cref="E:Microsoft.Phone.Controls.AutoCompleteBox.DropDownOpening" />
 /// event.
 /// </summary>
 /// <param name="e">A
 /// <see cref="T:Microsoft.Phone.Controls.RoutedPropertyChangingEventArgs`1" />
 /// that contains the event data.</param>
 protected virtual void OnDropDownOpening(RoutedPropertyChangingEventArgs<bool> e)
 {
     var handler = DropDownOpening;
     if (handler != null)
     {
         handler(this, e);
     }
 }
示例#11
0
        /// <summary>
        /// Begin opening the drop down by firing cancelable events, opening the
        /// drop-down or reverting, depending on the event argument values.
        /// </summary>
        /// <param name="oldValue">The original value, if needed for a revert.</param>
        private void OpeningDropDown(bool oldValue)
        {
            if (!IsCompletionEnabled)
            {
                return;
            }

            RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, true, true);

            // Opening
            OnDropDownOpening(args);

            if (args.Cancel)
            {
                _ignorePropertyChange = true;
                SetValue(IsDropDownOpenProperty, oldValue);
            }
            else
            {
#if !WINDOWS_PHONE
                RaiseExpandCollapseAutomationEvent(oldValue, true);
#endif
                OpenDropDown(oldValue, true);
            }

            UpdateVisualState(true);
        }
 /// <summary>
 /// Override UpDownBase&lt;T&gt;.OnValueChanging to do validation and
 /// coercion.
 /// </summary>
 /// <param name="e">Event args.</param>
 protected override void OnValueChanging(RoutedPropertyChangingEventArgs<double> e)
 {
     ValueChangingActions.DoPreTest(e);
     base.OnValueChanging(e);
     ValueChangingActions.DoTest(e);
 }
示例#13
0
 private void ICE_DropDownOpening(object sender, RoutedPropertyChangingEventArgs<bool> e)
 {
     if (!canDrop)
         e.Cancel = true;
 }
 public void TryCancel()
 {
     RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(null, true, false, false);
     Assert.IsFalse(args.IsCancelable);
     args.Cancel = true;
 }
 /// <summary>
 /// Raises the
 /// <see cref="E:System.Windows.Controls.AutoCompleteBox.DropDownClosing" />
 /// event.
 /// </summary>
 /// <param name="e">A
 /// <see cref="T:System.Windows.Controls.RoutedPropertyChangingEventArgs`1" />
 /// that contains the event data.</param>
 protected virtual void OnDropDownClosing(RoutedPropertyChangingEventArgs<bool> e)
 {
     RoutedPropertyChangingEventHandler<bool> handler = DropDownClosing;
     if (handler != null)
     {
         handler(this, e);
     }
 }
示例#16
0
        /// <summary>
        /// Begin closing the drop-down.
        /// </summary>
        /// <param name="oldValue">The original value.</param>
        private void ClosingDropDown(bool oldValue)
        {
            bool delayedClosingVisual = false;
            if (DropDownPopup != null)
            {
                delayedClosingVisual = DropDownPopup.UsesClosingVisualState;
            }

#if SILVERLIGHT
            RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, false, true);
#else
            RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, false, true, DropDownClosingEvent);
#endif

            OnDropDownClosing(args);

            if (_view == null || _view.Count == 0)
            {
                delayedClosingVisual = false;
            }

            if (args.Cancel)
            {
                _ignorePropertyChange = true;
                SetValue(IsDropDownOpenProperty, oldValue);
            }
            else
            {
                // Immediately close the drop down window:
                // When a popup closed visual state is present, the code path is 
                // slightly different and the actual call to CloseDropDown will 
                // be called only after the visual state's transition is done
                RaiseExpandCollapseAutomationEvent(oldValue, false);
                if (!delayedClosingVisual)
                {
                    CloseDropDown(oldValue, false);
                }
            }

            UpdateVisualState(true);
        }
		/// <summary>
		/// Handles the DropDownOpening event of the Realms control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="Microsoft.Phone.Controls.RoutedPropertyChangingEventArgs&lt;System.Boolean&gt;"/> instance containing the event data.</param>
		private void Realms_DropDownOpening(object sender, RoutedPropertyChangingEventArgs<bool> e)
		{
			if (!_isRealmControlTouched)
			{
				e.Cancel = true;
				acbRealms.IsDropDownOpen = false;
			}
		}
示例#18
0
        /// <summary>
        /// Raises the
        /// <see cref="E:System.Windows.Controls.AutoCompleteBox.DropDownClosing" />
        /// event.
        /// </summary>
        /// <param name="e">A
        /// <see cref="T:System.Windows.Controls.RoutedPropertyChangingEventArgs`1" />
        /// that contains the event data.</param>
        protected virtual void OnDropDownClosing(RoutedPropertyChangingEventArgs<bool> e)
        {
#if SILVERLIGHT
            RoutedPropertyChangingEventHandler<bool> handler = DropDownClosing;
            if (handler != null)
            {
                handler(this, e);
            }
#else
            RaiseEvent(e);
#endif
        }
示例#19
0
 private void InputBoxDropDownClosing(object sender, RoutedPropertyChangingEventArgs<bool> e)
 {
     var inputBox = (AutoCompleteBox)sender;
     var locationDescription = (LocationDescription)inputBox.SelectedItem;
     if (locationDescription != null)
     {
         if (inputBox.Name.Contains("start"))
         {
             this._viewModel.StartLocationText = locationDescription.DisplayName;
             this._viewModel.SelectedStartLocation = locationDescription;
         }
         else
         {
             this._viewModel.EndLocationText = locationDescription.DisplayName;
             this._viewModel.SelectedEndLocation = locationDescription;
         }
     }
 }