Hello Telerik,
I'm using a RadDiagram with a custom template for RadDiagramConnection. The function of this template is to rotate some text linked to the connector.
The following code is the style of my custom RadDiagramConnection :
<
Style
TargetType
=
"diagramscontrols:RadDiagramConnection"
x:Key
=
"RadDiagramConnectionStyle_RotateText"
>
<!--<
Setter
Property
=
"Background"
Value
=
"{StaticResource DiagramShape_Connection_Background}"
/>
<
Setter
Property
=
"Stroke"
Value
=
"{StaticResource DiagramShape_Connection_BorderBrush}"
/>-->
<
Setter
Property
=
"StrokeThickness"
Value
=
"1"
/>
<!--<Setter Property="ZIndex" Value="{StaticResource connectionZIndex}"/>-->
<
Setter
Property
=
"HorizontalContentAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"VerticalContentAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"FocusVisualStyle"
Value
=
"{x:Null}"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"diagramscontrols:RadDiagramConnection"
>
<
Grid
x:Name
=
"RootTemplate"
MinHeight
=
"0"
HorizontalAlignment
=
"Stretch"
>
<
VisualStateManager.VisualStateGroups
>
<
VisualStateGroup
x:Name
=
"SelectionStates"
>
<
VisualState
x:Name
=
"Selected"
/>
<
VisualState
x:Name
=
"SelectedInGroup"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"SelectedInGroupPath"
Storyboard.TargetProperty
=
"Visibility"
Duration
=
"0"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
<
VisualState
x:Name
=
"Unselected"
/>
<
VisualState
x:Name
=
"SelectedAsGroup"
/>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"EditMode"
>
<
VisualState
x:Name
=
"NormalMode"
/>
<
VisualState
x:Name
=
"NormalEditMode"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"NormalContent"
Storyboard.TargetProperty
=
"Visibility"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Collapsed</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"EditContent"
Storyboard.TargetProperty
=
"Visibility"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
<
VisualState
x:Name
=
"TextBoxEditMode"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"NormalContent"
Storyboard.TargetProperty
=
"Visibility"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Collapsed</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"EditTextBox"
Storyboard.TargetProperty
=
"Visibility"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
</
VisualStateGroup
>
</
VisualStateManager.VisualStateGroups
>
<
Path
x:Name
=
"DeferredPath"
Stroke
=
"{TemplateBinding Stroke}"
Opacity
=
"0.7"
Fill
=
"{TemplateBinding Background}"
StrokeThickness
=
"{TemplateBinding StrokeThickness}"
StrokeDashArray
=
"2 2"
/>
<
Path
x:Name
=
"SelectedInGroupPath"
Visibility
=
"Collapsed"
Stroke
=
"{StaticResource DiagramShape_Selected_BorderBrush}"
/>
<
Path
Stroke
=
"{TemplateBinding Stroke}"
Fill
=
"{TemplateBinding Background}"
StrokeThickness
=
"{TemplateBinding StrokeThickness}"
x:Name
=
"GeometryPath"
StrokeDashArray
=
"{TemplateBinding StrokeDashArray}"
/>
<
Grid
x:Name
=
"EdittingElement"
RenderTransformOrigin
=
"0.5 0.5"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
>
<!--TextBlock.TextAlignment="{Binding Tag.TextAlignement, RelativeSource={RelativeSource AncestorType=diagramscontrols:RadDiagramConnection}}"-->
<
Grid.RenderTransform
>
<
RotateTransform
>
<
RotateTransform.Angle
>
<
MultiBinding
Converter
=
"{StaticResource BoundsToAngleConverter}"
>
<
Binding
Path
=
"StartPoint"
RelativeSource
=
"{RelativeSource AncestorType=diagramscontrols:RadDiagramConnection}"
/>
<
Binding
Path
=
"EndPoint"
RelativeSource
=
"{RelativeSource AncestorType=diagramscontrols:RadDiagramConnection}"
/>
</
MultiBinding
>
</
RotateTransform.Angle
>
</
RotateTransform
>
</
Grid.RenderTransform
>
<
Border
Background
=
"Transparent"
/>
<
TextBlock
x:Name
=
"NormalContent"
Foreground
=
"{TemplateBinding Foreground}"
FontFamily
=
"{TemplateBinding FontFamily}"
FontSize
=
"{TemplateBinding FontSize}"
Text
=
"{TemplateBinding Content}"
TextAlignment
=
"{Binding Tag.TextAlignement, RelativeSource={RelativeSource AncestorType=diagramscontrols:RadDiagramConnection}}"
HorizontalAlignment
=
"{Binding Tag.HorizontalTextAlignement, RelativeSource={RelativeSource AncestorType=diagramscontrols:RadDiagramConnection}}"
VerticalAlignment
=
"Center"
/>
<!--<ContentPresenter x:Name="NormalContent" />-->
<
ContentPresenter
x:Name
=
"EditContent"
Visibility
=
"Collapsed"
Content
=
"{TemplateBinding Content}"
ContentTemplate
=
"{TemplateBinding EditTemplate}"
/>
<
TextBox
x:Name
=
"EditTextBox"
Visibility
=
"Collapsed"
Style
=
"{StaticResource EditTextBoxStyle_Connection}"
>
<
TextBox.InputBindings
>
<
KeyBinding
Key
=
"Enter"
Command
=
"ApplicationCommands.NotACommand"
/>
</
TextBox.InputBindings
>
</
TextBox
>
</
Grid
>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
However, I want that the text will be above of the connector. Moreover, I have some bad behaviors depending on the position of the Connector. I attached a file (arrowTexts) to show you these bad behaviors. Tell me if you want more examples.
I want to know if you can help me to find a solution to have the good text position.
Thank you very much !