private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UserControl uc = (UserControl)d; uc.TemplateChild = null; uc.RemoveLogicalChild(e.OldValue); uc.AddLogicalChild(e.NewValue); if (VisualTreeHelper.GetParent(uc) != null) { uc.InvalidateMeasureInternal(); } }
private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UserControl uc = (UserControl)d; uc.TemplateChild = null; uc.RemoveLogicalChild(e.OldValue); uc.AddLogicalChild(e.NewValue); if (uc.IsConnectedToLiveTree) { uc.InvalidateMeasureInternal(); } }