System.Windows.Controls.PopupHelper.BeforeOnApplyTemplate C# (CSharp) Method

BeforeOnApplyTemplate() public method

Should be called by the parent control before the base OnApplyTemplate method is called.
public BeforeOnApplyTemplate ( ) : void
return void
        public void BeforeOnApplyTemplate()
        {
            if(UsesClosingVisualState)
            {
                // Unhook the event handler for the popup closed visual state group.
                // This code is used to enable visual state transitions before 
                // actually setting the underlying Popup.IsOpen property to false.
                VisualStateGroup groupPopupClosed = VisualStates.TryGetVisualStateGroup(Parent, VisualStates.GroupPopup);
                if(null != groupPopupClosed)
                {
                    groupPopupClosed.CurrentStateChanged -= OnPopupClosedStateChanged;
                    UsesClosingVisualState = false;
                }
            }

            if(Popup != null)
            {
                Popup.Closed -= Popup_Closed;
            }
        }