how to set DataProperty in the Path in code? RRS feed

  • Question

  • i'm not using d2d in my project, my cpp code like this

    String^ datastring = ref new String(L"M 50,50 L 50,100 L 100,100 L 100,50 L 50,50 Z");

    however i get a exception that's

    First-chance exception at 0x76174B32 in Win8Client.exe: Microsoft C++ exception: Platform::FailureException ^ at memory location 0x0366E2A4. HRESULT:0x80004005

    is there something wrong? 

    Friday, January 4, 2013 2:41 AM


All replies

  • oh, i find DataProperty is readonly,but how can i set the data string in my cpp code?

    someone would help me ,please? thanks~

    Friday, January 4, 2013 2:45 AM
  • DataProperty is the identifier for the Data property. The actual Data property is read/write, but it takes a Geometry, not a string. The string is valid only in Xaml, not in code. You will need to build the contents from appropriate Geometry types, either directly or by parsing and building them from your string.

    For the one you list there you can use a PathGeometry with a PathFigure containing a PolyLineSegment.


    Friday, January 4, 2013 4:06 AM
  • thank you Rob, i'll try it later.

    for now i set the data="{binding}" in the xaml and set the datastring to the datacontext and it works~

    thanks again!

    Friday, January 4, 2013 5:07 AM