Today I had to write some code that would detect the Emulator we use to test WP7 Silverlight applications. For some reason though I had a really hard time finding the answer. Therefore I decided to post the solution here and to link the thread I finally did find which helped me find figure it out, which is this thread here.

Solution:

string DeviceTypeDetected = string.Empty;

switch (Microsoft.Devices.Environment.DeviceType)
{
    case Microsoft.Devices.DeviceType.Device:
        DeviceTypeDetected = "Real Device Detected!";
        break;
    case Microsoft.Devices.DeviceType.Emulator:
        DeviceTypeDetected = "Emulator Detected :(";
        break;
}