This is a migrated thread and some comments may be shown as answers.

Different colours and fills for custom shape elements

3 Answers 182 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Rajkumar
Top achievements
Rank 1
Rajkumar asked on 06 Aug 2014, 09:25 AM
Hi,

I would like to create a custom shape based on RadDiagramShape.

Lets say a rectangle and a small circle somewhere within it.

I want the rectangle and circle in different colors and fills.

What is the best way to achieve this ?

3 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 08 Aug 2014, 03:28 PM
Hello Rajkumar,
There are two ways to do this:
1) Use regular RadDiagramShape with custom style and an attached property for the circle's color (if you want to be able to use different colors)
2) use custom RadDiagramShape with custom style and an additional dependency property for the color.
I've attached a sample project so could you please examine it and see if this is what you're looking for.

Regards,
Zarko
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Rajkumar
Top achievements
Rank 1
answered on 08 Aug 2014, 03:43 PM
ok my custom shape is based on RectangleGeometry and EllipseGeometry.

var p = new PathGeometry();
var r = new RectangleGeometry(new Rect(new Point(0, 0), new Size(W, H)));
p.AddGeometry(r);
p.AddGeometry(new EllipseGeometry(new Point(0, 0),R,R);
Geometry = p;

Now, I need different colours for rectangle and ellipse.
How do I achieve this ?
0
Zarko
Telerik team
answered on 11 Aug 2014, 03:43 PM
Hello Rajkumar,
Unfortunately you can't have different colours for the ellipse and the geometry in this scenario because they are drawn by a single Path (its Data property is bound to the Geometry property) and they'll use the colour from its Fill property.
In order to have two different colours you'll have to use one of the methods that I suggested in my previous reply.

Regards,
Zarko
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Diagram
Asked by
Rajkumar
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Rajkumar
Top achievements
Rank 1
Share this question
or