/// <summary> /// Initializes a new instance of the /// <see cref="PickerAutomationPeer"/> class. /// </summary> /// <param name="owner">The Picker that is associated to this /// AutomationPeer.</param> protected PickerAutomationPeer(Picker owner) : base(owner) { }
/// <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); } }