public virtual void AutoCompleteBoxAutomationPeerTypeAndClass() { AutoCompleteBox acb = new AutoCompleteBox(); AutoCompleteBoxAutomationPeer peer = null; TestAsync( acb, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(acb) as AutoCompleteBoxAutomationPeer, () => Assert.AreEqual(AutomationControlType.ComboBox, peer.GetAutomationControlType(), "Unexpected AutomationControlType!"), () => Assert.AreEqual("AutoCompleteBox", peer.GetClassName(), "Unexpected ClassType!")); }
public virtual void ControlCreatesPeer() { AutoCompleteBox acb = new AutoCompleteBox(); AutoCompleteBoxAutomationPeer peer = null; TestAsync( acb, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(acb) as AutoCompleteBoxAutomationPeer, () => Assert.IsNotNull(peer, "AutoCompleteBox peer should not be null!"), () => Assert.AreEqual(acb, peer.Owner, "AutoCompleteBox should be owner of the peer!")); }
/// <summary> /// IsDropDownOpenProperty property changed handler. /// </summary> /// <param name="d">AutoCompleteTextBox that changed its IsDropDownOpen.</param> /// <param name="e">Event arguments.</param> private static void OnIsDropDownOpenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { AutoCompleteTextBox source = d as AutoCompleteTextBox; // 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); AutoCompleteBoxAutomationPeer peer = FrameworkElementAutomationPeer.FromElement(source) as AutoCompleteBoxAutomationPeer; 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); if (source.View == null || source.View.Count == 0) { delayedClosingVisual = false; } // 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); } }