Preface
Storing and manipulating data plays an important role in making any mobile phone effective in business applications or any other data-driven application. Windows Phone 7.5 Data Cookbook covers topics such as how to bind data easily using databinding techniques, how to save data in local storage for later retrieval, how to format XML for data storage, exploring on-device databases for storage options, how to consume cloud data sources like OData, REST, and WCF, and finally, how to scale applications using the most popular MVVM pattern.
This book has a wide range of simple to complex recipes, which help you understand basic concepts of data handling. You will be able to apply the knowledge you gained from these recipes to build your own apps effectively. Instead of diving into writing complex sample applications for the first time, this book focuses on simplifying the concepts in an easy step-by-step fashion using simple straightforward samples.
Windows Phone 7.5 Data Cookbook will make you an expert in the areas of data access and storage. When you are ready to start developing a data-driven Windows Phone 7 application, you will be well equipped with the different scenarios to implement and store data.
What this book covers
Chapter 1, Databinding to UI Elements, shows how to create data binding to User Interface elements using any data sources such as CLR Objects, files, XML, or external databases. Various topics such as Element Binding, DataContext, DataTemplates, DataMode, and Data Converters are covered. Finally, a simple app is created applying the different databinding concepts.
Chapter 2, Isolated Storage, demonstrates how to open, create, and save user settings to local isolated storage for later consumption, using name/value pairs or images or XML files.
Chapter 3, XML as a Data Store, covers how to open a local or remote XML file, how to navigate the XML file to search for specific information, and finally, how to serialize XML to an object.
Chapter 4, Using Open Data, explains how to consume OData with a simple URI and then how to search with different operations. Finally, it demonstrates how to execute CRUD operations with OData.
Chapter 5, Using On-device Databases, explores different on-device database options available such as commercial Perst, open source SQLite, and Microsoft's SQL CE. It also explains how to use LINQ to SQL in SQL CE.
Chapter 6, Representational State Transfer—REST, covers basic concepts of consuming REST services and calling different social media services such as Twitter and RSS Feeds. Finally, it demonstrates how to build a simple REST service.
Chapter 7, Windows Communication Foundation–WCF, demonstrates how to create and consume simple web services and understand LINQ features. It demonstrates how to build services using ADO.NET Entity Data Model and LINQ to SQL. Both these technologies significantly automate building service layers quickly and effectively.
Chapter 8, Model View ViewModel, introduces us to basic concepts of the MVVM design pattern and how it can be implemented using simple samples. MVVM Light toolkit is introduced by demonstrating different scenarios of applications. Finally, a sample is created to demonstrate how easy it will be to maintain a MVVM-patterned application.
What you need for this book
The following is the list of software needed for this book. Different software and tools are used during the course of this book to demonstrate specific concepts or techniques.
Microsoft Visual Studio 2010 Express for Windows Phone http://www.microsoft.com/visualstudio/en-us/products/2010-editions/windows-phone-developer-tools
Microsoft Visual Studio Web Developer 2010 Express http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-web-developer-express
SQL Server 2008 Manager Express http://www.microsoft.com/download/en/details.aspx?id=26729
SQL CE Edition 4.0 http://go.microsoft.com/fwlink/?LinkId=212219
SQLite Studio http://sqlitestudio.one.pl/
SQLite Client http://sqlitewindowsphone.codeplex.com/releases
Microsoft Web Matrix http://www.asp.net/web-pages
Perst.Net http://www.mcobject.com
MVVMLight toolkit http://mvvmlight.codeplex.com/
Phone 7 toolkit http://silverlight.codeplex.com/releases
Who this book is for
This book is for developers who understand the language features of C#, XAML, and Silverlight technologies, and want to build data-driven apps, or line-of-business (LOB) applications using Windows Mobile platform. It helps if the developer has some understanding of Metro design philosophy and user interface guidelines from Microsoft. Also, this book helps developers of other mobile platforms to convert their apps to Windows Phone 7.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "First, create a private variable for DataClass
before the MainPage
constructor."
A block of code is set as follows:
namespace Recipe2 { public class DataClass { public string Name { get; set; } public string Notes { get; set; } } }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
<TextBlock x:Name="ApplicationTitle" Text="Phone7 Recipes" Style="{StaticResource PhoneTextNormalStyle}"/>
Any command-line input or output is written as follows:
datasvcutil /uri:http://services.odata.org/(S(bltvbobia1rthiavqczdcr1u))/OData/OData.svc/ /out:.\EditODataModel.cs /Version:2.0 /DataServiceCollection
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the New Query icon in the tab bar and then Execute the selected query."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>
, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <suggest@packtpub.com>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com>
with a link to the suspected pirated material. We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com>
if you are having a problem with any aspect of the book, and we will do our best to address it.