Object serialization to XML
In this recipe, we shall explore how to serialize an object and then deserialize the XML back to an object.
Getting ready
Open a new Phone 7 application project and save it as Recipe5_SerializeXml
. Press F5 and make sure it compiles without any errors.
How to do it...
In the following steps, we will create sample data to save and serialize it to XML. We will then open it using the deserialize method and then display it in a list box.
Open the
MainPage.xaml
file; add a button to trigger the saving and opening of the serialization. The XAML should look like the following code snippet:<Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!--TitlePanel contains the name of the application and page title--> <StackPanel x:Name="TitlePanel" Grid.Row="0"Margin="12,17,0,28"> <TextBlock x:Name="ApplicationTitle...