public static void OnDropDownControlChanged <T>(T owner, PopupControlBase oldControl, PopupControlBase newControl) where T : FrameworkElement, IDropDownControlHost { if (owner.PopupHost == null) { SetOwnerLogicalChild(owner, newControl); } else { owner.PopupHost.DropDownControl = newControl; } }
private static void SetOwnerLogicalChild <T>(T owner, PopupControlBase dropDownControl) where T : FrameworkElement, IDropDownControlHost { var depObj = dropDownControl as DependencyObject; owner.LogicalChild = depObj?.GetLogicalParent() == null ? dropDownControl : null; }