Export (0) Print
Expand All

Windows Phone 7 Data

In this article you will learn how you can access, store, display, and work with data within a Windows Phone application. You will also see how you can leverage data binding to build advanced user interfaces with minimal coding.

Most Windows Phone applications consume, produce, or store some form of data. Because the Windows Phone development platform is based on Silverlight, the set of APIs for working with data is consistent with those for the desktop. However, there are some considerations that are specific to building applications for Windows Phone, such as how to handle occasionally connected scenarios and the use of isolated storage. This article covers consuming data from the web, how to store data using isolated storage, and how to display data using data binding. It also looks at how you can accept input from the user and save it via a remote web service.

Unless otherwise specified the contents of this article apply to both Windows Phone OS 7.0 and 7.1. There are some new features and changes introduced with Windows Phone OS 7.1, such as LINQ to SQL and OData support, which will also be covered in this article.

This article is aimed mainly at .NET and Silverlight developers who are familiar with the basics of the Windows Phone Platform. Readers should have both Visual Studio 2010 and the latest release of the Windows Phone SDK installed. Readers should also have a solid grasp of the latest C# programming concepts.

The development and design tools for Windows Phone can be downloaded from http://create.msdn.com. This includes Visual Studio 2010, Expression Blend 4 Express editions for Windows Phone, and a Windows Phone emulator. While it is not necessary to have a real device for working through the examples, it is recommended that you test any application on a device prior to submitting it to the Windows Phone Marketplace for certification.

One of the most important parts of any Windows Phone application is the data that is to be presented or collected. A unique set of considerations apply to mobile applications, which need to be understood when planning the data side of your application.

Unlike desktop computers that are typically stationary in nature, mobile phones are always on the move. If you’ve tried to make a phone call from inside an elevator, you’ve probably noticed the lack of signal strength. Even as phone networks become more pervasive, occasionally no network is available. Creating a good Windows Phone application is not just about creating a good design; it’s also about planning for how your application functions regardless of network availability.

Regarding the data for your Windows Phone application you need to consider where your data will be located, how it will be accessed, and how it will be displayed. The answers to these questions rely on your understanding of the different types of data that you are working with. Is the data real time data? In this case, you probably want to poll the service at frequent intervals to get the latest information. How long is the data relevant? If data is relevant for an extended period of time, rather than having to retrieve it from the service each time the application is run, you can cache the data on the device and simply display the cached data until it expires. The answers to these types of questions can help you understand the nature of the data.

The discussion on working with data on Windows Phone is broken into five sections:

  • Accessing Data:  Discover is the best way to access data from a remote service. Look at the classes available to make service requests and moves on to discussing the use of web services and OData.

  • Storing Data with Isolated Storage and LINQ to SQL: Once your application is populated you will see how you can store this data using application settings, files, and folders located within isolated storage, or by using a relational database via LINQ to SQL.

  • Displaying Data with Data Binding:  See how to use data binding to present the data to the user and how the Model-View-ViewModel (MVVM) pattern can be used to connect data with the interface. This section also shows you how to bind data to a number of the standard controls, such as the ListBox, Panorama, and Pivot controls.

  • Saving Data to the Web:  In addition to displaying data, most applications accept some form of user input. Learn how to collect input from the user and how you can then submit this data to a remote service.

  • Occasionally Connected Scenarios:  This final section offers guidance around building occasionally connected applications. This includes showing how you can test for network availability and how you can synchronize data between your application and a service.

Show:
© 2014 Microsoft