Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
Windows Phone Zone is brought to you in partnership with:

I have worked for several companies as a senior software developer and lead developer. I bave enterprise level programming experience on Web, Silverlight, and Windows Phone 7. I am a MVP in Device Application Development since 2011. Jevgeni is a DZone MVB and is not an employee of DZone and has posted 40 posts at DZone. You can read more from them at their website. View Full User Profile

Three properties that I use for almost every Windows Phone application

06.21.2011
Email
Views: 2103
  • submit to reddit
It's so easy to get up and running with your first Windows Phone app!  Just pick up the FREE toolkit from Microsoft, register at AppHub, and start checking out some fundamental tutorials.

In this post I will tell you which three properties I use for almost every one of my Windows Phone applications. The first property is used by me to determine if the application is running in trial mode or full mode. Second property is provided to identify if the application is running on low-memory device and the last property is used to detect if user has selected a dark or light background theme in Windows Phone settings. All of those properties were described in detail earlier, but I have decided to collect them in a single post.

Is it the trial version or full version?

A few months ago I wrote a post Determining license mode in Windows Phone 7 apps and below is a property taken from that post. You can simulate if application is running in Emulator in trial mode by modifying the “emulatorIsTrial” variable.

private const bool _emulatorIsTrial = false;
 
public bool IsTrialMode
{
    get
    {
        if (Microsoft.Devices.Environment.DeviceType
               == Microsoft.Devices.DeviceType.Emulator)
        {
            return _emulatorIsTrial;
        }
        return (new LicenseInformation().IsTrial());
    }
}

 

Is it a low memory device?

To take advantage of devices that have more than 256 Mb of RAM available I have created a special property in one of my previous posts. This property helps you to determine the available memory on a device. Here’s what this property looks like:

private const bool _emulatorIsLowMemory = false;
 
public bool IsLowMemoryDevice
{
    get
    {
        if (Microsoft.Devices.Environment.DeviceType
            == Microsoft.Devices.DeviceType.Emulator)
        {
            return _emulatorIsLowMemory;
        }
        else
        {
            return (long)DeviceExtendedProperties.GetValue("DeviceTotalMemory")
                <= 268435456;
        }
    }
}

Is it a light or dark theme?

Finally, here is a property from my last post to detect if the user has selected a dark or light theme background in Windows Phone settings.

References
Tags:
Published at DZone with permission of Jevgeni Tšaikin, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

The Windows Phone Microzone, which is supported by Microsoft, is your one-stop-shop for news, tutorials, perspectives, and research on the mobile platform that is making waves in smartphone ecosystem.