Hello again!
I am creating custom RadDiagramShape as it is written in Telerik documentation: https://docs.telerik.com/devtools/wpf/controls/raddiagram/howto/create-custom-shape . It contains 2 borders and an image inside of them. When I am doing it according to the documentation, rotation and zoom after rotation works weird with ancor-points of this CustomControl. When I am doing 2 borders and an image inside RadDiagramShape inside xaml without any CustomControl it works as it should.
The picture of weird behaviour is attached (after rotating of both figures).
Would you be so kind to tell me how I can fix this weird behaviour of my CustomControl?
This is my .cs code
public class RasterObject : RadDiagramShapeBase
{
static RasterObject()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(RasterObject), new FrameworkPropertyMetadata(typeof(RasterObject)));
}
public static readonly DependencyProperty ContrastyBorderBrushProperty =
DependencyProperty.Register("ContrastyBorderBrush", typeof(Brush),
typeof(RasterObject), new FrameworkPropertyMetadata(Brushes.Transparent));
// .NET Property wrapper
public Brush ContrastyBorderBrush
{
get { return (Brush)GetValue(ContrastyBorderBrushProperty); }
set { SetValue(ContrastyBorderBrushProperty, value); }
}
public static readonly DependencyProperty SourceProperty =
DependencyProperty.Register("Source", typeof(ImageSource),
typeof(RasterObject));
// .NET Property wrapper
public ImageSource Source
{
get { return (ImageSource)GetValue(SourceProperty); }
set { SetValue(SourceProperty, value); }
}
}
This is my style code:
<
Style
TargetType
=
"{x:Type local:RasterObject}"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type local:RasterObject}"
>
<
Border
BorderBrush
=
"{TemplateBinding ContrastyBorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
>
<
Border
Background
=
"{TemplateBinding Background}"
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
>
<
Image
Source
=
"{TemplateBinding Source}"
Stretch
=
"Fill"
/>
</
Border
>
</
Border
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
This is my Xaml code:
<
telerik:RadDiagram
IsBackgroundSurfaceVisible
=
"True"
>
<
telerik:RadDiagramShape
Position
=
"50, 50"
Background
=
"Transparent"
BorderBrush
=
"Transparent"
>
<
Border
BorderBrush
=
"Red"
BorderThickness
=
"13"
>
<
Border
BorderBrush
=
"Blue"
BorderThickness
=
"23"
>
<
Image
Source
=
"/Images/MainToolbar/Arc.png"
Stretch
=
"Fill"
/>
</
Border
>
</
Border
>
</
telerik:RadDiagramShape
>
<
imageeditor:RasterObject
BorderBrush
=
"Gray"
BorderThickness
=
"10"
ContrastyBorderBrush
=
"White"
Source
=
"/Images/MainToolbar/Arc.png"
/>
</
telerik:RadDiagram
>
Best regards,
Tatiana