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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:41:47+00:00 2026-05-21T04:41:47+00:00

I have a need to parse Bezier Path Strings, but apparently the System.Windows.Media.Geometry version

  • 0

I have a need to parse Bezier Path Strings, but apparently the System.Windows.Media.Geometryversion in the .Net CF framework doesn’t have the Parse() method that is available in it’s normal counterpart. However, entering the following XAML does work, so there must be a way the system parses the Path Data String.

<Path Stroke="Blue" Data="M 0 0 Q 10 10 20 0"/>

Any clue on how I can initiate this parsing myself with a custom string outside XAML?

I ofcourse could also try to write my own parser using regex or so, but I would prefer not to handle this myself, since the framework clearly is capable of it.

Update

When using the suggested XAMLReader, I get a strange Exception when I set a StrokeThickness to the newly created Path:

path.StrokeThickness = strokeWidth; //ArgumentException ??? (strokeWidth = 6)

When I change codepath to render using my manual parser, everything works correctly.
Am I missing something here? Nothing changes except the parser.

Manually Generating Data:

        //"M {0} {1} Q {2} {3} {4} {5}"

        String regex_input = @"M (\d+) (\d+) Q (\d+) (\d+) (\d+) (\d+)";
        Regex regex = new Regex(regex_input);
        Match match = regex.Match(pathData);

        int startx = int.Parse(match.Groups[1].Value);
        int starty = int.Parse(match.Groups[2].Value);

        int controlx = int.Parse(match.Groups[3].Value);
        int controly = int.Parse(match.Groups[4].Value);

        int endx = int.Parse(match.Groups[5].Value);
        int endy = int.Parse(match.Groups[6].Value);

        PathGeometry geo = new PathGeometry();
        PathFigure figure = new PathFigure();
        figure.StartPoint = new Point(startx, starty);

        QuadraticBezierSegment quad = new QuadraticBezierSegment();
        quad.Point1 = new Point(controlx, controly);
        quad.Point2 = new Point(endx, endy);

        figure.Segments.Add(quad);

        geo.Figures.Add(figure);

        path.Data = geo;

Using XamlReader

        String formattedXAMLInput = String.Format("<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Stroke='Black' Data='{0}'/>", pathData);
        Path xamlpath = (Path)XamlReader.Load(formattedXAMLInput);
        Geometry xamldata = xamlpath.Data;
        path.Data = xamldata;
  • 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-21T04:41:48+00:00Added an answer on May 21, 2026 at 4:41 am

    We don’t currently expose an API for the path mini-language parser. It’s internal to the XAML parser.

    You can, however, create Path objects dynamically based on mini-language strings, using the XamlReader:

    Path path = XamlReader.Load("<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Stroke='Blue' Data='M 0 0 Q 10 10 20 0'/>") as Path;
    

    Note that this won’t actually expose the details of the geometry through the API to you, but you can display the resulting Path in your app.

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

Sidebar

Related Questions

i have a input tag which is non editable, but some times i need
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
I have a login.jsp page which contains a login form. Once logged in the
I have a snippet to create a 'Like' button for our news site: <iframe
We manage a site for a medical charity. They have a number of links
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a new web app that is packaged as a WAR as part
This is beyond both making sense and my control. That being said here is
Is there a way to test if a collection is already initialized? try-catch only?

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.