There are some additional changes for certain features that are worth reviewing. If you feel in the need to launch a background processing operation and the
async/await keywords aren't enough,
Task.Run is the method you should call to do that. However, whenever possible, try to use the new asynchronous pattern. Forget about both lower level threads and the
BackgroundWorker component, you'll always be working with tasks. You will be able to use most of the synchronization primitives you already know from .NET Framework and the lightweight synchronization primitives that Microsoft added in .NET Framework 4.0.
The main XML parser in .NET for Windows Store apps is XML Linq. Thus, you should only use either
XmlWriter whenever you require a low-level abstraction and XML Linq isn't enough.
Developing a New Windows Store App Based with Predefined Navigation
In Visual Studio 2012, follow these steps to create a new Windows Store app based on the Grid App template:
- Select File | New | Project… The New Project dialog box will appear.
- Select Templates | Visual C# | Windows Store in the left pane. The templates list will display six templates for the selected target (see Figure 6).
Figure 6: The New Project dialog box displaying the details about the Grid App (XAML) template for Windows Store apps.
- Select Grid App (XAML). The template generates a three-page project for a Windows Store app with navigation features. The app allows the user to navigate among grouped items arranged in a grid and there are dedicated pages to display group and item details. In this case, I want to explain how to consume Web services in a Windows Store app, and therefore, this template provides me with a complete predefined navigation mechanism that I can easily customize. It is useful to learn the user experience Microsoft promotes. However, once you get used to it, you will find it most convenient to start working with the Blank App (XAML) template.
- Enter the desired name in the Name textbox. I'll use
DrDobbsAppbecause my sample app will consume a Web service and will organize and display some content from Dr. Dobb's. The interaction of apps with services is very important, and therefore, I want to dive deep on the new
System.Net.HttpClientwith this sample app.
- Finally, click OK and the IDE will create a new solution with a Windows Store Grid app.
If this is the first time you're creating a project that targets Windows Store, the IDE will display a dialog box requesting your authorization to install a developer license for Windows 8 (see Figure 7). The developer license allows you to install, develop, test, and evaluate Windows Store apps before submitting them for testing and certification to the Windows Store. Once you have a developer license installed, you can run Windows Store apps that haven't been tested and certified by the Windows Store, so you must be careful when running apps from non-trusted sources.
Figure 7: The dialog box that the IDE displays when you try to create a project that targets Windows Store.
The license is free and you only need a Microsoft account. Make sure you read the privacy statement, click I agree, and login with your Microsoft account. Once you have the license, a dialog box will provide information about the expiration date for the license (see Figure 8). You will need to renew the license before it expires.
Figure 8: A dialog box provides information about the developer license expiration date.