Tuesday, December 7, 2010

Windows Phone 7 Quick Tip #23 – Determine if you are running on the Emulator or a Device

When you are developing your Windows Phone 7 application you might want to know if you are running on an emulator or on the device.  Fortunately there’s a property for that:

Microsoft.Devices.Environment.DeviceType

It can have the values:

Microsoft.Devices.DeviceType.Device
Microsoft.Devices.DeviceType.Emulator

So a simple check of:

if(Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Device)
             MessageBox.Show(“On the emulator”);

will let you know that you are on the emulator.

-twb

No comments:

Post a Comment