public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.part_Popup = this.GetTemplateChild("PART_Popup") as Popup;
     if (this.part_Popup == null)
     {
         throw new NullReferenceException("'{0}' template part is not found on 'PopupToggle' control " + ((object)"PART_Popup"));
     }
     PopupToggle.SetPopupPlacement(this.part_Popup, this.PopupPlacment);
 }
        private static void OnPopupPlacementChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            PopupToggle popupToggle = dependencyObject as PopupToggle;
            Popup       partPopup   = popupToggle.part_Popup;

            if (partPopup == null)
            {
                return;
            }
            PopupToggle.SetPopupPlacement(partPopup, popupToggle.PopupPlacment);
        }