Categories: Blog

Hello, Windows Phone

I have managed to acquire a preproduction version of the new Windows phone manufactured by LG, and have been given permission to write about it (most of it, anyway). In coming weeks, I’ll be blogging about the phone and providing key insights for developers looking to build apps for it with Silverlight.

I’ll start with something simple: the Back button. Every Windows phone has a Back button that functions like a browser’s Back button. I like this, because on the iPhone, I often have to go all the way back to the main screen just to back out of what I’m currently doing.

The Back button is accompanied by a Start button and a Search button, and Windows phones have other buttons as well: for example, a power button and a camera-shutter button. But the Back button is the only one that you can hook in software. When pressed, the Back button fires a BackKeyPress event. The UI Design and Interaction Guide for Windows Phone 7 says this about handling BackKeyPress events:

Developers should only implement Back Button behaviors that navigate back or dismiss context menus or modal dialog boxes. All other implementations are prohibited.

This warning is more than a formality. If an app contravenes this directive, Microsoft won’t allow it to be published in the Marketplace.

For the most part, developers won’t need to hook BackKeyPress events because the Back button works without any program intervention. However, one practical use for BackKeyPress events is to prompt the user to save data before navigating away from your app, or to let the user cancel a Back-button navigation event. Here’s a simple example that hooks the Back button and asks the user to confirm that they want to navigate away:

this.BackKeyPress +=

    new EventHandler<System.ComponentModel.CancelEventArgs>(OnBackKeyPress);

      .

      .

      .

void OnBackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)

{

    MessageBoxResult result = MessageBox.Show("Are you sure?", "Confirm",

        MessageBoxButton.OKCancel);

    e.Cancel = !(result == MessageBoxResult.OK);

}

Here’s how it looks in the Windows phone emulator:

 

In discussions with Microsoft personnel, it was agreed that this is a legitimate use of BackKeyPress events and that it would not prevent an app from being published in the Marketplace.

Jeff Prosise

Recent Posts

8-Step AWS to Microsoft Azure Migration Strategy

Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…

3 weeks ago

How to Navigate Azure Governance

 Cloud management is difficult to do manually, especially if you work with multiple cloud…

4 weeks ago

Why Azure’s Scalability is Your Key to Business Growth & Efficiency

Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…

1 month ago

Unlocking the Power of AI in your Software Development Life Cycle (SDLC)

https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…

2 months ago

The Role of FinOps in Accelerating Business Innovation

FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…

2 months ago

Azure Kubernetes Security Best Practices

Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…

2 months ago