Different colours and fills for custom shape elements

4 posts, 0 answers
  1. Rajkumar
    Rajkumar avatar
    9 posts
    Member since:
    May 2014

    Posted 06 Aug 2014 Link to this post

    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 ?

  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 08 Aug 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rajkumar
    Rajkumar avatar
    9 posts
    Member since:
    May 2014

    Posted 08 Aug 2014 in reply to Zarko Link to this post

    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 ?
  5. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 11 Aug 2014 Link to this post

    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.
     
Back to Top