Add gestures to your Windows Phone 7 application

Jul 8, 2012 by

As it turns out, it is extremely easy to add gestures to your Windows Phone app. All you need to do is add a reference to the Silverlight Toolkit


xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

Then add the following code to any UI element (button, textbox etc…) that you want the gesture to be applied to and implement the listeners in your .cs file


<toolkit:GestureService.GestureListener>
     <toolkit:GestureListener 
         DoubleTap="GestureListenerDoubleTap"
         Hold="GestureListenerHold"/>
</toolkit:GestureService.GestureListener>

Last step is the implementation of the listeners:


private void GestureListenerDoubleTap(object sender, GestureEventArgs e)
{
    MessageBox.Show("Double tap gesture");
}

and


private void GestureListenerHold(object sender, GestureEventArgs e)
{
    MessageBox.Show("Hold gesture");
}

That’s it. It is THAT simple

read more

How to determine theme accent color on Windows Phone

Jul 8, 2012 by

That’s how to determine theme accent color on Windows Phone 7


// Determine the accent color.
Color currentAccentColorHex =
    (Color)Application.Current.Resources["PhoneAccentColor"];

switch (currentAccentColorHex.ToString())
{
    case "#FF1BA1E2": currentAccentColor = "blue"; break;

    case "#FFA05000": currentAccentColor = "brown"; break;

    case "#FF339933": currentAccentColor = "green"; break;

    case "#FFE671B8": currentAccentColor = "pink"; break;

    case "#FFA200FF": currentAccentColor = "purple"; break;

    case "#FFE51400": currentAccentColor = "red"; break;

    case "#FF00ABA9": currentAccentColor = "teal (viridian)"; break;

    // Lime changed to #FFA2C139 in Windows Phone OS 7.1.
    case "#FF8CBF26":
    case "#FFA2C139": currentAccentColor = "lime"; break;

    // Magenta changed to # FFD80073 in Windows Phone OS 7.1.
    case "#FFFF0097":
    case "#FFD80073": currentAccentColor = "magenta"; break;

    // #FFF9609 (previously orange) is named mango in Windows Phone OS 7.1.
    case "#FFF09609": currentAccentColor = "mango (orange)"; break;

    // Mobile operator or hardware manufacturer color
    default: currentAccentColor = "custom eleventh color"; break;
}
read more

How to determine theme background color on Windows Phone

Jul 8, 2012 by


// Determine the visibility of the dark background.
Visibility darkBackgroundVisibility =
    (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];

// Write the theme background value.
if (darkBackgroundVisibility == Visibility.Visible)
{
    textBlock1.Text = "background = dark";
}
else
{
    textBlock1.Text = "background = light";
}
read more

Windows Phone 7 “hidden” shortcut keys for the simulator

Jun 29, 2012 by

Ever wondered how you can type on your Wp7 simulator using your keyboard?

Here’s a list of useful keyboard shortcuts for the WP7 emulator which includes the answer to the above question.

Key Description
F1 Use F1 key on the keyboard instead of back button on the phone
F2 Use the key F2 on the keyboard for the Windows key in the Windows Phone 7
Pageup Enables the keyboard in the emulator when the focus is on the textbox
PageDown Disables the keyboard in the emulator
F3 To open the Bing Search
F7 To Activate the Physical Camera
F9 Increase the Volume
F10 Decrease the volume

read more

Windows Phone (WP7) stats for 2011 infographics

Jan 18, 2012 by

An interesting infographics was published on the WP7 developer blog.

The most interesgint points that we saw are that 56% of the users can purchase apps via carrier billing which is amazing number for a young platform. Android did not have carrier billing for at least a year into its existence if not two years. Which was a significant barrier for selling paid apps since billing mechanism was not oiled like on Apple’s iOS platform where all the users have iTunes setup with their billing information.

Surprising enough the Games category is not as huge as we’d expect it to be. Taking a little smaller percentage than the Entertainment apps in the app to category distribution. But in the paid apps category Games are far ahead of any other category in purchases which of course should not be surprising, although this trend is not so prominent on other platforms.

Overall it seems pretty good info and quite useful for developers. Enjoy!

read more

WP7 – what makes live tile unique?

Jan 10, 2012 by

If you were playing with the “Live Tiles” from the latest (at the moment) OS update to the Windows Phone code named “Mango”, you might have been wondering what makes Live tiles unique and how many live tiles can be placed on the home screen of the user. Accidentally I found out that what makes the live tile unique is the tile reference or the tile URI

a usual way to create a tile would be:


ShellTile.Create(new Uri("/GotoPage.xaml?param1=value1&param2=value2, UriKind.Relative), tileData);

so whenever you change the value1 and value 2, a new live tile can be created.

Happy coding and have fun with the live tiles!

read more