Convert from string to data in silverlight?

前端 未结 1 1114
时光说笑
时光说笑 2021-01-20 19:20

Basically I\'m trying to do this:

Path path = new Path( ); 

string sData = \"M 250,40 L200,20 L200,60 Z\";

var converter = TypeDescriptor.GetConverter( typ         


        
1条回答
  •  遇见更好的自我
    2021-01-20 19:39

    Try this:-

      Path path = XamlReader.Load("") as Path;
    

    Edit

    Should have been:

      public static GeneratePath(string data)
      {
          string pathEnvelope = "")
          return XamlReader.Load(String.Format(pathEnvelope, data)) as Path;
      }
    

    Usage:-

      string data = "M 250,40 L200,20 L200,60";
    
      Path path = GeneratePath(data);
    

    See follow up question: xaml parse exception when attempting to load xaml from codebehind

    0 讨论(0)
提交回复
热议问题