/// <summary> /// Note: this method is only executed when the Loaded event is fired, /// so setting DragThumbTemplate or ConnectorDecoratorTemplate /// properties after will have no effect. /// </summary> /// <param name="sender"></param> /// <param name="routedEventArgs"></param> private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { if (Template != null) { var contentPresenter = Template.FindName("PART_ContentPresenter", this) as ContentPresenter; if (contentPresenter != null) { var contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement; if (contentVisual != null) { // Find your templates in here var drag = Template.FindName("PART_DragThumb", this) as DragThumb; if (drag != null) { var template = GetDragThumbTemplate(contentVisual); if (template != null) { drag.Template = template; } } var connector = Template.FindName("PART_ConnectorDecorator", this) as Control; if (connector != null) { connector.Template = ConnectorXamlFactory.CreateTemplate("ConnectorDecoratorTemplate", BlockModel.Connectors); } } } } }
public void RedrawModel(BlockViewModel model) { var connector = model.Template.FindName("PART_ConnectorDecorator", model) as Control; if (connector != null) { connector.Template = ConnectorXamlFactory.CreateTemplate("ConnectorDecoratorTemplate", model.BlockModel.Connectors); } OnModelRedraw(this, model.BlockModel); }