this code converts any controls or object to xml
if I saved this
the saved xml would be looks like:
<Grid Name="g" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Image Source="pack://application:,,,/WpfApplication1;component/Images/Picture3.jpg" Stretch="Fill" Name="image1" Width="200" Height="150" Margin="96,36,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Name="button1" Width="75" Height="23" Margin="352,71,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">Button</Button>
<TextBox Name="textBox1" Width="120" Height="23" Margin="62,198,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" xml:space="preserve" />
<Label Name="label1" Height="28" Margin="270,213,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">Label</Label>
</Grid>
I used this code to save this:
System.IO.StreamWriter s = new System.IO.StreamWriter(@"d:\grid.xml");
s.WriteLine(System.Windows.Markup.XamlWriter.Save(g));
s.Close();
g is the name of the grid which contains all controls
my question:
can I reverse this, read this xml file and represent it on a window