locked
Getting the string value from a Path Geometry in C#

    Question

  • I'm trying to get the string value of the Data value of a Path.  

    On WinPhone8 I could easily do a path.Data.toString();  however with the 8.1 update (universal app) I'm only getting the class name back.

    I'm looking for the string value of the path.Data.  i.e. "M17.198,13.194C19.021,13.194 20.566,11.686 20.566,9.864 20.566,8.03 19.021,6.523 17.198,6.523 15.39,6.523 13.832,8.03 13.832,9.864 13.832,11.687 15.39,13.194 17.198,13.194 M0.1,18.119L0.1,18.119C0.05,18.068 0,17.967 0,17.867 0,17.679 0.176,17.528 0.365,17.528L11.018,17.528C11.533,17.528 11.947,17.113 11.947,16.597 11.947,16.195 11.772,15.931 11.382,15.706L1.746,11.121C1.571,11.02 1.445,10.831 1.445,10.58 1.445,10.417 1.494,10.267 1.62,10.141 1.62,10.141 26.91,-12.208 82.928,9.45L98.304,1.95C98.454,1.875 98.63,1.825 98.794,1.825 99.46,1.825 100,2.365 100,3.031 100,3.244 99.924,3.446 99.824,3.634L90.754,14.928 99.824,26.185C99.924,26.386 100,26.587 100,26.826 100,27.466 99.46,28.007 98.794,28.007 98.63,28.007 98.454,27.956 98.304,27.881L82.928,20.381C82.928,20.379,29.384,41.648,0.1,18.119"


    Any suggestions?

    Thanks!

    Friday, October 03, 2014 5:51 PM

Answers

  • You'll need to iterate the path objects and recreate the string. It isn't stored once the Xaml is interpreted and the Path created.
    Friday, October 03, 2014 7:53 PM
    Owner
  • There's a PathGeometryParser in the code attached to this article. I ported this code from Silverlight to Windows 8 Store, so it may be close to the Universal API.

    Tuesday, October 07, 2014 7:06 AM

All replies

  • You'll need to iterate the path objects and recreate the string. It isn't stored once the Xaml is interpreted and the Path created.
    Friday, October 03, 2014 7:53 PM
    Owner
  • That's too bad, since it was prior to the update...  the toString() method worked perfectly
    Sunday, October 05, 2014 4:29 PM
  • There's a PathGeometryParser in the code attached to this article. I ported this code from Silverlight to Windows 8 Store, so it may be close to the Universal API.

    Tuesday, October 07, 2014 7:06 AM