Over a million developers have joined DZone.

Three properties that I use for almost every Windows Phone application

· Mobile Zone

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.

Topics:

Published at DZone with permission of Jevgeni Tšaikin. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}