Tag Archives: Developers

Another year, another MIX

Last year in April, the place to be was Las Vegas, NV for MIX 10. During this conference  Windows Phone 7 was officially introduced. Immediately after MIX 10 the development tools were available for download. Also, the great content that was presented during MIX 10 is still available for you to watch. It seems hard to believe that we have been developing Windows Phone 7 applications for less than a year. We really have come a long way. Windows Phone 7 is released in a number of countries, devices are available in many more countries and the list of applications being released on Marketplace is growing rapidly.

Update: It is no longer possible to vote for MIX11 sessions. Thank you very much if you voted for one (or more) of my sessions that are listed below.

This year, before attending MIX, there is a call to action for everybody (especially for you since you are reading this blog post). You are in control of voting for a number of sessions of which the most favorite sessions will be presented at MIX. Amongst the Windows Phone 7 sessions that are up for voting, three were submitted by me. I am counting on you to help me become part of MIX 11. If you like the things I am writing on this blog or if you have seen me speaking in the past, or just because you are visiting this website, make sure to vote for my MIX 11 sessions. You can vote for all these sessions by clicking on the links. You can only vote for each session once on a physical machine, but of course I can’t prevent you against voting multiple times on different machines. Here are the sessions I submitted for voting (clicking on the individual links will bring you to the voting page for the particular sessions):

  • Windows Phone 7: Application Architecture

    When you start developing Silverlight applications for Windows Phone 7 using Visual Studio 2010, you might be tempted to use code behind to connect your user interface (written in XAML) to your functionality (written in C#). In this sample filled presentation, Maarten Struys explains why this relatively easy approach is not necessarily the best approach to create testable, maintainable and great Windows Phone 7 applications. During the presentation, the power of DataBinding in Silverlight will be revealed and a traditional application, using code behind will be converted into an application that makes use of the MVVM design pattern.

  • Windows Phone 7 and the Cloud: The Sky is The Limit

    Windows Phone 7 is a powerful platform for which you can create great stand-alone Silverlight based applications. To create Windows Phone 7 applications with limitless processing resources and virtually unlimited storage capacity, Windows Azure and Windows Phone 7 are great companions. In this sample filled presentation, Maarten Struys shows you how to create a Windows Phone 7 application together with a Windows Azure based back-end. He explains how the application can efficiently communicate with the back-end using a REST based Web Client interface. He also shows you how to efficiently cache information locally on the phone to make Windows Phone 7 applications operate independent of network connectivity. After attending this session you know how to create Windows Phone 7 applications that are as powerful as server applications.

  • Fast starting and State Saving Windows Phone 7 Applications

    In this sample filled presentation, Maarten Struys shows you the impact of Tombstoning on Windows Phone 7 applications. He shows you how to store the application’s state and individual page state information efficiently. He also explains how your application can start fast and efficiently by making use of multithreading and asynchronous programming techniques. After attending this presentation, your Windows Phone 7 Tombstone headaches will be history and your end users will be happy with your fast starting applications.

Thank you very much for voting! I really hope to see you in Las Vegas between April 12 – April 14 for MIX 11. If you are planning to visit MIX 11, make sure to register before February 11 to benefit from a nice discount.

Using Silverlight or XNA in a Windows Phone 7 Application

Windows Phone 7 applications can either be Silverlight based or XNA Framework based. Often, it is obvious which framework to use for a particular type of application. Typically, games will either use Silverlight or XNA, depending on the desired functionality they need. All other types of applications typically will be Silverlight based although from a technical point of view it is possible to create ‘non-game’ applications using XNA as well.

Silverlight uses an event driven model for your application. Events are raised by the operating system (often as a result of some user action) and an application can either react on the event or ignore the event. Inside an application you will ignore the majority of events that will be raised, but act on a number of specific events to achieve the desired functionality of the application. A Silverlight based application is often battery friendly, especially if it only reacts on user actions. In this type of scenario, the application will be idle for most of the time. However, if repetitive behavior is needed for an application (for instance, a clock application might want to update the time every second), a timer object can be used that periodically raises an event on which your application can react. In this scenario you have to keep in mind that you are draining the battery faster, because your application is repeatedly executing code. If your application wakes up to react on a raised event, it will execute code that is defined in an event handler for a particular event. The event handler will get information from the operating system about the source that raised the event. That source, for instance, can be a User Interface element, an expiring timer or a hardware interrupt. Because the event sender is known, the application can assure that it executes the code, belonging to a specific event.

The XNA Framework uses a loop driven model for your application. Periodically your application will wake up and it is up to the application to determine if something needs to be done. In order to achieve this, every XNA Framework application maintains a ‘game loop’ that executes 60 times per second (when using default  values). It is the application’s responsibility to first Update the state of the application, for instance by getting user input, updating variables etc. Once a new application state is determined, the application is responsible to Draw to the Windows Phone 7 screen accordingly. Both Update and Draw will execute periodically, with Update taking priority over Draw. Note that these types of applications will drain the battery whenever the user is playing a game, because the application will wake up frequently, even if there is no work to do in either Update or Draw.

From a developer’s perspective, there are a number of reasons to either develop a Silverlight based Windows Phone 7 application or a XNA Framework based Windows Phone 7 application. Silverlight contains a nice collection of ready to use controls like buttons, text boxes etc. You can modify or extend these controls inside your own applications and you can create new controls. The XNA Framework contains functionality to make it relative easy for you to create 2D sprites that support rotation, scaling, stretching and filtering. There is also extensive support to create 3D graphics, including functionality for lighting and shading to create a great 3D experience. When making use of the XNA Framework however, you are responsible to create all of your artwork that is visible inside your application.

In certain situations, a distinct choice between Silverlight and XNA is not that easy to make. Also, in some scenario’s you might want to combine Silverlight with XNA Framework functionality. Using XNA Framework specific functionality inside a Silverlight application will be the topic of another blog entry. For now, if you want to know more about developing applications for Windows Phone 7 and if you want to read more about the initial choice between Silverlight and the XNA Framework, make sure to read this high level overview in the Windows Phone 7 documentation.

Be careful with Theme Resources for Windows Phone

As a developer you of course know that end users can select different themes on a Windows Phone 7. You most likely also know that you can access theme settings through Theme Resources from inside your Windows Phone 7 application. However, what you should realize is that the Theme Resources are used throughout your entire application, and that you can change the appearance of theme aware controls by modifying the Theme Resources inside your application. This is something I recently found out while working on a little application that utilizes the PhoneAccentBrush. My first attempt to use a copy of the PhoneAccentBrush looked like this:

  1. normalBrush = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
  2. normalBrush.Opacity = 0.3;

After executing this code somewhere in my application, it turned out that some of the controls inside my application looked wrong, for instance the currently selected item in a ListPicker and the checked ToggleSwitch:

ThemeAwareControls(1)

Instead of the selected item showing up in green, which was my selected theme color, the selected item looked really pale. At the same time, the checked ToggleSwitch looked really dark. It took me a few seconds to realize what was going on here. Especially since the same screen showed up nicely some times and ‘wrong’ at other times. What really happened here was the following. Each time I executed the above shown code snippet before displaying the settings screen, the ListPicker showed up pale. However, displaying the settings screen without executing the code snippet made the ListPicker appear crisp and colorful. Of course my mistake was a real beginner’s mistake. I thought I created a copy of the PhoneAccentBrush, but that was not the case. Instead I just assigned a brush variable to the PhoneAccentBrush and I modified the PhoneAccentBrush through the brush variable, thus influencing all UI controls that make use of the PhoneAccentBrush inside my application. By doing the proper thing, creating a new brush, based on the PhoneAccentBrush, my problems were history. This is how I created a copy of the PhoneAccentBrush for local use inside my application:

  1. SolidColorBrush b = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
  2.  
  3. normalBrush = new SolidColorBrush(b.Color);
  4. normalBrush.Opacity = 0.3;

Changing the Opacity on a copy of the PhoneAccentBrush did not influence the appearance of theme aware UI controls any longer. This is what the ListPicker looked like after solving my problem:

ThemeAwareControls(2)

In this way I could create a User Interface for a little application that is theme aware, but modified the accent color slightly for exclusive use inside my own application. This is an example of a very simple problem that can take you some time to solve. The solution for this problem was easy, but understanding what you are really doing can prevent mistakes like this one. Each time I run into one of these issues I will definitely blog about them.