Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3627570
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:54:19+00:00 2026-05-18T23:54:19+00:00

I have the need for drawing in the same drawing with lines of different

  • 0

I have the need for drawing in the same drawing with lines of different color, thickness etc.

I can create two instances of PathGeometry, but I can’t set color on them.

I can create two instances of Path, but can’t get them displayed in my control.

What am I doing wrong?

Thanks for any comments!

Anders, Denmark.

Code below only displays “collection” in my control, but I thought it could be a starting point for answers…

        var pathFigure1 = new PathFigure(new Point(0, 0),
                                         new List<PathSegment> {new LineSegment(new Point(10, 10), true)}, false);
        var pathFigure2 = new PathFigure(new Point(20, 20),
                                         new List<PathSegment> {new LineSegment(new Point(30, 30), true)}, false);


        var g1 = new PathGeometry(new List<PathFigure> {pathFigure1});
        var g2 = new PathGeometry(new List<PathFigure> {pathFigure2});

        var p1 = new System.Windows.Shapes.Path
                     {
                         Data = g1,
                         Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 0))
                     };
        var p2 = new System.Windows.Shapes.Path
                     {
                         Data = g2,
                         Stroke = new SolidColorBrush(Color.FromRgb(170, 87, 170))
                     };

        var content = new Canvas();
        content.Children.Add(p1);
        content.Children.Add(p2);

        Content = content;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:54:19+00:00Added an answer on May 18, 2026 at 11:54 pm

    You have started on the right approach, a geometry defines a ‘shape’, so don;t worry that you cannot set its colour. A Path turns the geometry into a visual representation on the screen, so here you can set the color and stroke thickness.

    Your problem is at the very last step, you are setting the content property of your control. Typically this property is used to associate some data object with a control, you then supply a template which is its visual representation.

    What you need to do is add your paths as children of a panel.

    For example, add a Canvas, or a Grid to your control. Then add your two paths to the Grid / Canvas via their Children collection property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drawing app where the user can draw lines with their finger,
I have a drawing function that just takes an HDC. But I need to
I have been developing the application for drawing and I need to detect double
I have need for a function pointer that takes two arguments and returns a
I have some code to change how listbox act. I can change the color
I need to be able to let multiple instances of the same form be
How can I use both of these in the same UIView correctly? I have
I have a view with custom drawRect method which has two text lines drawn
In my opengl app, I am drawing the same polygon approximately 50k times but
I have been developing the application, and I need that drawingg is executed in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.