Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

How do I deserialize this?

C#
public static void SerializeToXML(MainWindow window, Canvas canvas, int dpi, string filename)
    {
        string mystrXAML = XamlWriter.Save(canvas);
        FileStream filestream = File.Create(filename);
        StreamWriter streamwriter = new StreamWriter(filestream);
        streamwriter.Write(mystrXAML);
        streamwriter.Close();
        filestream.Close();
    }


Thanks
Posted
Updated 2-Jan-14 19:14pm
v3
Comments
BillWoodruff 3-Jan-14 0:56am    
Please tag your question: WPF ? SilverLight ? WinRT ? HTML5 ?

CodeProject is your friend:

http://www.codeproject.com/Tips/318905/Use-Xaml-XamlServices-to-Serialize-or-Deserialize
Sergey Alexandrovich Kryukov 3-Jan-14 2:58am    
Deserialize? With DPI?!...
—SA
shers 3-Jan-14 3:06am    
yes. Here's the serialized text.

<Canvas Background="#FFEBEBEB" Name="DesigningCanvas" Margin="20,20,20,60" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><textbox width="177" cursor="Hand" canvas.left="50" canvas.top="30">It's a TextBox control<Label Width="110" Cursor="Hand" Canvas.Left="50">It's a Label control</Label><Button Cursor="Hand" Canvas.Left="50" Canvas.Top="60">It's a Button control</Button><radiobutton name="radioButton1" height="30" cursor="Hand" canvas.left="50" canvas.top="90"><stackpanel orientation="Horizontal"><Label>It's a Custom RadioButton Control with CheckBox control</Label><checkbox margin="7,7,7,7"><checkbox name="checkBox1" height="16" cursor="Hand" canvas.left="50" canvas.top="120">It's a CheckBox control<ListBox Name="listBox1" Width="151" Height="100" Cursor="Hand" Canvas.Left="489" Canvas.Top="160"><ListBoxItem>It's a ListBox control</ListBoxItem></ListBox></Canvas>

1 solution

just do it reversely. you can search MSDN how to use them. Good luck
StreamWriter -> StreamReader
XamlWriter.save -> XamlReader.load
 
Share this answer
 
Comments
shers 3-Jan-14 8:24am    
That doesn't work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900