System.Windows.Controls.AutoCompleteBox.OnApplyTemplate C# (CSharp) Méthode

OnApplyTemplate() public méthode

Builds the visual tree for the T:System.Windows.Controls.AutoCompleteBox control when a new template is applied.
public OnApplyTemplate ( ) : void
Résultat void
        public override void OnApplyTemplate()
        {
#if !SILVERLIGHT
            if(TextBox != null)
            {
                TextBox.PreviewKeyDown -= OnTextBoxPreviewKeyDown;
            }
#endif
            if(DropDownPopup != null)
            {
                DropDownPopup.Closed -= DropDownPopupClosed;
                DropDownPopup.FocusChanged -= OnDropDownFocusChanged;
                DropDownPopup.UpdateVisualStates -= OnDropDownPopupUpdateVisualStates;
                DropDownPopup.BeforeOnApplyTemplate();
                DropDownPopup = null;
            }

            base.OnApplyTemplate();

            // Set the template parts. Individual part setters remove and add 
            // any event handlers.
            Popup popup = GetTemplateChild(ElementPopup) as Popup;
            if(popup != null)
            {
                DropDownPopup = new PopupHelper(this, popup) { MaxDropDownHeight = MaxDropDownHeight };
                DropDownPopup.AfterOnApplyTemplate();
                DropDownPopup.Closed += DropDownPopupClosed;
                DropDownPopup.FocusChanged += OnDropDownFocusChanged;
                DropDownPopup.UpdateVisualStates += OnDropDownPopupUpdateVisualStates;
            }
            SelectionAdapter = GetSelectionAdapterPart();
            TextBox = GetTemplateChild(ElementTextBox) as TextBox;
#if !SILVERLIGHT
            if(TextBox != null)
            {
                TextBox.PreviewKeyDown += OnTextBoxPreviewKeyDown;
            }
#endif
            Interaction.OnApplyTemplateBase();

            // If the drop down property indicates that the popup is open,
            // flip its value to invoke the changed handler.
            if(IsDropDownOpen && DropDownPopup != null && !DropDownPopup.IsOpen)
            {
                OpeningDropDown(false);
            }
        }