Book Image

Windows Phone 7.5 Data Cookbook

By : Ramesh Thalli
Book Image

Windows Phone 7.5 Data Cookbook

By: Ramesh Thalli

Overview of this book

Windows Phone 7.5 Mango contains support for apps written in Silverlight or XNA. These apps can store data on the device, and also load and manipulate data from "the cloud" and other web services.This Windows Phone 7.5 Data Cookbook has a range of recipes to help you apply data handling concepts. You will be able to apply the knowledge gained from these recipes to build your own apps effectively. This Windows Phone 7.5 Data Cookbook starts with data binding concepts at the UI layer and then shows different ways of saving data locally and externally in databases. The book ends with a look at the popular MVVM software design pattern. The recipes contained in this book will make you an expert in the areas of data access and storage.
Table of Contents (15 chapters)
Windows Phone 7.5 Data Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.

  1. 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...