neethu
neethu

Reputation: 98

Dynamically generate xaml string from a UIElement object

I have a Windows.UI.Xaml.Shape.Path object.How can l generate the xaml string corresponding to that Path object.

Input : Path object

Desired Output : "Path Data="M 120,10 200,L300" Stroke="Black"""

or is there any way to calculate Path Data from Path Bounds property?

Upvotes: 2

Views: 1448

Answers (1)

S3ddi9
S3ddi9

Reputation: 2151

try this

string s_output = System.Windows.Markup.XamlWriter.Save(yourpath);

and to reload use

System.IO.StringReader stringReader = new System.IO.StringReader(s_output);
System.Xml.XmlReader xmlReader = System.Xml.XmlTextReader.Create(stringReader, new System.Xml.XmlReaderSettings());
Path yourpath= (Path)System.Windows.Markup.XamlReader.Load(xmlReader);

Upvotes: 3

Related Questions