Hi Telerik,
I'm using a custom RadDiagramTextShape in RadDiagram :
<
Style
TargetType
=
"diagramscontrols:RadDiagramTextShape"
>
<
Setter
Property
=
"Background"
Value
=
"Transparent"
/>
<
Setter
Property
=
"BorderBrush"
Value
=
"Transparent"
/>
<
Setter
Property
=
"StrokeThickness"
Value
=
"1"
/>
<
Setter
Property
=
"RenderTransformOrigin"
Value
=
"0.5 0.5"
/>
<
Setter
Property
=
"FontSize"
Value
=
"{StaticResource DiagramShapeFontSize}"
/>
<
Setter
Property
=
"FontFamily"
Value
=
"Segoe UI"
/>
<!--<
Setter
Property
=
"TextBlock.TextAlignment"
Value
=
"{Binding Tag.HorizontalTextAlignement, RelativeSource={RelativeSource AncestorType=diagramscontrols:RadDiagramTextShape}}"
/>
<
Setter
Property
=
"TextBlock.TextWrapping"
Value
=
"Wrap"
/>-->
<
Setter
Property
=
"HorizontalContentAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"VerticalContentAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"diagrams:DiagramBehaviors.TextWrapping"
Value
=
"Wrap"
/>
<
Setter
Property
=
"ZIndex"
Value
=
"2"
/>
<
Setter
Property
=
"Padding"
Value
=
"4"
/>
<
Setter
Property
=
"FocusVisualStyle"
Value
=
"{x:Null}"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"diagramscontrols:RadDiagramTextShape"
>
<
Grid
UseLayoutRounding
=
"True"
>
<
VisualStateManager.VisualStateGroups
>
<
VisualStateGroup
x:Name
=
"MouseStates"
>
<
VisualState
x:Name
=
"Normal"
/>
<
VisualState
x:Name
=
"MouseOver"
/>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"ActiveConectionStates"
>
<
VisualState
x:Name
=
"NormalActiveConnectionState"
/>
<
VisualState
x:Name
=
"ActiveConnectionInsideShape"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"ActiveSelectedBorder"
Storyboard.TargetProperty
=
"Visibility"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"ConnectorsAdornerVisibilityStates"
>
<
VisualState
x:Name
=
"ConnectorsAdornerCollapsed"
/>
<
VisualState
x:Name
=
"ConnectorsAdornerVisible"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"ConnectorsControl"
Storyboard.TargetProperty
=
"Visibility"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0"
>
<
DiscreteObjectKeyFrame.Value
>
<
Visibility
>Visible</
Visibility
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
</
VisualStateGroup
>
<
VisualStateGroup
x:Name
=
"SelectionStates"
>
<
VisualState
x:Name
=
"Selected"
/>
<
VisualState
x:Name
=
"SelectedInGroup"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Duration
=
"0"
Storyboard.TargetName
=
"SelectedInGroupBorder"
Storyboard.TargetProperty
=
"Visibility"
>
<
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
>
<
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
>
<
Grid
>
<
Border
Background
=
"{TemplateBinding Background}"
Visibility
=
"Visible"
BorderThickness
=
"{Binding ElementName=RectangleBorder, Path=StrokeThickness, FallbackValue=1}"
>
<
Border.BorderBrush
>
<
VisualBrush
>
<
VisualBrush.Visual
>
<
Rectangle
StrokeDashArray
=
"{TemplateBinding StrokeDashArray}"
Stroke
=
"{TemplateBinding BorderBrush}"
StrokeThickness
=
"{TemplateBinding StrokeThickness}"
Width
=
"{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
Height
=
"{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"
x:Name
=
"RectangleBorder"
/>
</
VisualBrush.Visual
>
</
VisualBrush
>
</
Border.BorderBrush
>
</
Border
>
<
Border
x:Name
=
"SelectedInGroupBorder"
Visibility
=
"Collapsed"
BorderBrush
=
"{StaticResource DiagramShape_Selected_BorderBrush}"
BorderThickness
=
"2"
/>
<
Border
x:Name
=
"ActiveSelectedBorder"
Visibility
=
"Collapsed"
BorderBrush
=
"{StaticResource DiagramShape_ActiveSelected_BorderBrush}"
BorderThickness
=
"2"
/>
<
TextBlock
x:Name
=
"NormalContent"
Margin
=
"{TemplateBinding Padding}"
HorizontalAlignment
=
"{Binding Tag.HorizontalTextAlignement, RelativeSource={RelativeSource AncestorType=diagramscontrols:RadDiagramTextShape}}"
TextAlignment
=
"{Binding Tag.TextAlignement, RelativeSource={RelativeSource AncestorType=diagramscontrols:RadDiagramTextShape}}"
VerticalAlignment
=
"Center"
diagrams:DiagramBehaviors.TextWrapping
=
"Wrap"
TextWrapping
=
"Wrap"
Text
=
"{TemplateBinding Content}"
/>
<
primitives:ConnectorsControl
x:Name
=
"ConnectorsControl"
ItemsSource
=
"{TemplateBinding Connectors}"
Visibility
=
"Collapsed"
ItemContainerStyle
=
"{TemplateBinding ConnectorStyle}"
/>
</
Grid
>
<
Grid
x:Name
=
"PART_RotationalPart"
Margin
=
"2"
>
<
ContentPresenter
x:Name
=
"EditContent"
Visibility
=
"Collapsed"
HorizontalAlignment
=
"{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment
=
"{TemplateBinding VerticalContentAlignment}"
Content
=
"{TemplateBinding Content}"
ContentTemplate
=
"{TemplateBinding EditTemplate}"
/>
<
TextBox
x:Name
=
"EditTextBox"
BorderThickness
=
"0"
Margin
=
"0"
Style
=
"{StaticResource EditTextBoxStyle}"
VerticalAlignment
=
"Stretch"
Visibility
=
"Collapsed"
>
<
TextBox.InputBindings
>
<
KeyBinding
Key
=
"Enter"
Command
=
"ApplicationCommands.NotACommand"
/>
</
TextBox.InputBindings
>
</
TextBox
>
</
Grid
>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
<
Style
TargetType
=
"TextBox"
x:Key
=
"EditTextBoxStyle"
>
<
Setter
Property
=
"TextWrapping"
Value
=
"Wrap"
/>
<
Setter
Property
=
"AcceptsReturn"
Value
=
"True"
/>
<
Setter
Property
=
"TextAlignment"
Value
=
"Center"
/>
<
Setter
Property
=
"HorizontalAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"VerticalAlignment"
Value
=
"Center"
/>
<
Setter
Property
=
"Margin"
Value
=
"4"
/>
<
Setter
Property
=
"FontSize"
Value
=
"11"
/>
<
Setter
Property
=
"FontFamily"
Value
=
"Segoe UI"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Black"
/>
<
Setter
Property
=
"Padding"
Value
=
"2"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"TextBox"
>
<
Grid
x:Name
=
"RootElement"
UseLayoutRounding
=
"True"
>
<
Rectangle
Stroke
=
"{StaticResource DiagramShape_EditTextBox_BorderBrush}"
StrokeDashArray
=
"3 3"
Fill
=
"{StaticResource DiagramShape_EditTextBox_Background}"
/>
<
ScrollViewer
Padding
=
"{TemplateBinding Padding}"
BorderThickness
=
"0"
Background
=
"Transparent"
Foreground
=
"{TemplateBinding Foreground}"
VerticalContentAlignment
=
"{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment
=
"{TemplateBinding HorizontalContentAlignment}"
x:Name
=
"PART_ContentHost"
/>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
My nominal scenario is :
1- Select Text tool
2- Select size of the shape (drag the mouse in the diagram)
3- Write text in the TextBlock in the shape
4- Open settings of the shape, and select Background and BorderBrush
5- Shape is saved (with Serialization and after in database)
The problem is when I'm going in settings (step 4) without wrote text (step 3). In this case, the shape is unusable (If I click on it, I can't update the text), and not saved (when I leave the diagram and go back, the shape isn't here).
I can't access to fired events and I don't know where come from this problem.
Can you help me ?
Thank you.