How do you clone a path resource in Silverlight? -
I have the resources defined in an XAML file, as follows:
Lt; Path x: key = "Mypath" data = "M14.773241,18.080208 c12.373256,18.080208 10.239 936,19.30687 10.239 936,27.573483 L10.239 936,36.106766 C10.239 936,45.440037 12.586588,46.506699 14.986573,46.506699 C 18.613216,46.506699 19.359879,42.400059 19.359879, 35.3601 L19.359879,27.733482 C19.359879,20.05353 17.386541,18.080208 14.773241,18.080208 Jade M 14.879907,11.786915 C17.973221,11.786915 22.293194,13.013573 24.906511,17.920212 C26.773167,21.386856 27.519829,27.093487 27.519829,32.213455 C27.519829, 34.506775 27.306496,41.706726 24.906511,46.453365 C23.626518,49.013351 20.906536,52.799992 15.199905,52.799992 C2.1333201,52.799992 2.1333201,37.600086 2.1333201,32.160122 C2.1333201,28.05348 2.1333201,22.666847 4.4266391,18.453541 C5.8666301,15.840225 8.639946,11.786915 14. 8,7 9, 9 07, 11.786 915 Z. "/>
I want to add more than one "example" of this path (and many others) to a stackpack. Of course, I can not just add "Mypath" to the panel because it is already a child of another container.
However, I can not be able to clone the path. I have tried:
path clone = new path () {data = source.Data};
But there is no luck ... the price is going out of expectation limits.
Finally, I tried to dig into the source. Data (a PathGeometry), but there are no pathfiggers in it ... I do not know why, because I copy it from the Resources section directly to a panel, because the path again presents.
What gives?
Thank you, Sergio
Put the path data in a string resource:
& lt; Page .Resources & gt; & Lt; System: string x: key = "path data" & gt; M 14.773241,18.080208 c12.373256,18.080208 10.239 936,27.57,343 L10.239 936,36.106766 C10.239 936,45.440037 12.586588,46.506699 14.986573,46.506699 C 18.613216,46.506699 19.359879,42.400059 19.359879,35.3601 L19.359879, 27.733482 C19 359879,20.05353 17.386559,18.080208 14.773241,18.080208 z M14.879907,11.786915 C17.973221,11.786915 22.293194,13.013573 24.906511,17.920212 C26.773167,21.386856 27.519829,27.093487 27.519829,32.213455 C27.519829,34.506775 27.306496,41.706726 24.906511,46.453365 C23. 626518,49.013351 20.906536,52.79999215.199905,52.799 992 C2.1333201,37.600086 2.1333201,32.160122 C2.1333201,28.05348 2.1333201,22.666847 4.4266391,18.453541 C5.8666301,15.840225 8.639946,11.786915 14.879907,11.786915 Z & lt; / System: String & gt; & Lt; /Page.Resources>
and to use it:
& lt; Path x: name = "path1" data = "{static resource path path}" = "blue". .. / & gt; & Lt; Path x: name = "path2" data = "{static resource path path}" Fill = "red" ... />
You will need it in your XML declaration:
xmlns: system = "clr-namespace: system; assembly = mscorlib"
< / Pre>If you want to create a path to the program using a common path string, then there is some special functionality missing in the Silverlight that is WPF - so you have to press it:
string path xaml = @ "& lt; path xmlns =" "http://schemas.microsoft.com/winfx/2006/xaml/presentation" "xmlns: x =" "http: // schemas .microsoft.com / winfx / 2006 / Xaml "" data = "" path_data_goce_ here "/> gt; Path = (path) system. Windows. Markup. Aksmelarder. Load (Pthaksamel);
Comments
Post a Comment