How to save object changes to its XAML?
For example, in a WPF or Silverlight app I have:
<Rectangle Height="100" Width="200" Name="rectangle1" Stroke="Black" />
then in code I change its properties to:
rectangle1.Height = 50;
rectangle1.Width = 50;
How could I save these cha开发者_开发技巧nges to the object's XAML?
Like this:<Rectangle Height="50" Width="50" Name="rectangle1" Stroke="Black" />
If you'd like to output the XAML of your rectangle after changing the properties you specified, then you might want to checkout the XamlWriter
class. There's a method called Save
that will return a string containing the XAML equivalent of the object passed in.
Check it out here. Hope this helps!
精彩评论