protected void SetConnectorDecoratorTemplate(DesignerItem item) { if (item.ApplyTemplate() && item.Content is UIElement) { ControlTemplate template = DesignerItem.GetConnectorDecoratorTemplate(item.Content as UIElement); Control decorator = item.Template.FindName("PART_ConnectorDecorator", item) as Control; if (decorator != null && template != null) { decorator.Template = template; } } }
void DesignerItem_Loaded(object sender, RoutedEventArgs e) { // if DragThumbTemplate and ConnectorDecoratorTemplate properties of this class // are set these templates are applied; // Note: this method is only executed when the Loaded event is fired, so // setting DragThumbTemplate or ConnectorDecoratorTemplate properties after // will have no effect. if (base.Template != null) { ContentPresenter contentPresenter = this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter; if (contentPresenter != null) { UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement; if (contentVisual != null) { DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb; Control connectorDecorator = this.Template.FindName("PART_ConnectorDecorator", this) as Control; if (thumb != null) { ControlTemplate template = DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate; if (template != null) { thumb.Template = template; } } if (connectorDecorator != null) { ControlTemplate template = DesignerItem.GetConnectorDecoratorTemplate(contentVisual) as ControlTemplate; if (template != null) { connectorDecorator.Template = template; } } } } } }