开发者

How to save object changes to its XAML?

开发者 https://www.devze.com 2023-02-08 18:32 出处:网络
For example, in a WPF or Silverlight app I have: <Rectangle Height=\"100\" Width=\"200\" Name=\"rectangle1\" Stroke=\"Black\" />

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消