Posted 04 Apr 2012 Link to this post
public class PrimitiveShape : RadDiagramShapeBase{ public PrimitiveShape() : base() { this.DefaultStyleKey = typeof(PrimitiveShape); }}<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:local="clr-namespace:GSAB.RSProduction.Modules.OfficeTools.ViewModel.Workflow"> <Style TargetType="local:PrimitiveShape"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:PrimitiveShape"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=OctagonShape}" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style></ResourceDictionary> I'm trying to implement a simple primitive shape by inheriting from RadDiagramShapeBase, but when adding it to the diagram no connectors is showing. Any suggestions on what I'm doing wrong here would be appreciated.
public
class
PrimitiveShape : RadDiagramShapeBase
{
PrimitiveShape() :
base
()
this
.DefaultStyleKey =
typeof
(PrimitiveShape);
}
<
ResourceDictionary
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local
"clr-namespace:GSAB.RSProduction.Modules.OfficeTools.ViewModel.Workflow"
>
Style
TargetType
"local:PrimitiveShape"
Setter
Property
"Template"
Setter.Value
ControlTemplate
Border
Background
"{TemplateBinding Background}"
BorderBrush
"{TemplateBinding BorderBrush}"
BorderThickness
"{TemplateBinding BorderThickness}"
telerik:RadDiagramShape
Geometry
"{telerik:CommonShape ShapeType=OctagonShape}"
/>
</
ItemsControl
x:Name
"ConnectorsAdorner"
ItemsSource
"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ConnectorPoints}"
Visibility
"Collapsed"
ItemsControl.ItemsPanel
ItemsPanelTemplate
primitives:ConnectorsPanel
Posted 05 Apr 2012 Link to this post
Could you please give us more information on what you are trying to achieve? Are you inheriting the base RadDiagramShape class to extend its funcionality or to have a different look and feel? If it is the latter, then you can just change the default template or content template, without subclassing it. Moreover, in the inherited shape's template you should not be using the original shape. I would recommend using the default shape style as a base for your custom one. The default styles we are shipping in the installation directory. Its full path should look something like this : C:\Program Files (x86)\Telerik\RadControls for Silverlight Q1 2012\Themes\Metro\Themes\Metro\DiagramShapes.xaml
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>