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 6948169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:47:13+00:00 2026-05-27T13:47:13+00:00

I am new at using path in a wpf and I do not know

  • 0

I am new at using path in a wpf and I do not know how to convert a segment of xaml code to C# code. Could someone help me with this? I cite following the xaml code and then my attempt to convert it. What the C# code lacks of? One more thing I ‘d like to ask is if a grid is enough so as a path to appear in the window.

<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
  <PathGeometry.Figures>
    <PathFigureCollection>
      <PathFigure StartPoint="10,100">
        <PathFigure.Segments>
          <PathSegmentCollection>
            <QuadraticBezierSegment Point1="200,200" Point2="300,100" />
          </PathSegmentCollection>
        </PathFigure.Segments>
      </PathFigure>
    </PathFigureCollection>
  </PathGeometry.Figures>
</PathGeometry>

My C# code:

Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = new PathFigureCollection();

PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10, 100);
myPathFigure.Segments = new PathSegmentCollection();
QuadraticBezierSegment theSegment = new QuadraticBezierSegment();
theSegment.Point1 = new Point(200, 200);
theSegment.Point2 = new Point(100, 300);
myPathFigure.Segments.Add(theSegment);
myPathGeometry.Figures.Add(myPathFigure);
  • 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-27T13:47:13+00:00Added an answer on May 27, 2026 at 1:47 pm

    You have to add following line at the end,

    myPath.Data = myPathGeometry;
    

    And you should add x:Name to your <Grid> as <Grid x:Name='myGrid'>

    And add one more line,

    myGrid.Children.Add(myPath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using (FileStream fileStream = new FileStream(path)) { // do something } Now I know
I have the following code: using (BinaryReader br = new BinaryReader( File.Open(FILE_PATH, FileMode.Open, FileAccess.ReadWrite)))
I'm new to using open source libraries in production code so when it says
The closest I get is using new FileInfo(path).FullPath , but as far as I
Maybe this is a very silly question but I'm new using django. I have
This is C# version: public static IEnumerable<string> ReadLinesEnumerable(string path) { using ( var reader
I bind my wpf window to app layer class (WindowVM.cs) using DataContext in Window.xaml.cs
I'm relatively new to C# and .Net, and this is my first WPF project,
I'm trying to generate new path using boost::filesystem as follows #include <iostream> #include <string>
I'm new using CXF and Spring to make RESTful webservices. This is my problem:

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.