Two quick Windows Phone Dev Tips

Posted: August 28, 2011 in Mobile

This will be a short post on sharing two little things I learnt while “Mangofying” one of my Windows Phone apps.

One:

We often use global placeholders/variables in your apps. These are usually defined in the App.xaml.cs and accessed throughout the project off of the App object. My good friend Travis Smith (@legomasternet) pointed out recently that a shortcut way to access these global variables is desirable through the use of static properties. Here’s how I did it in the most recent Windows Phone project:

 
        // This is defined in App.xaml.cs
        public static new App Current
        {
            get { return Application.Current as App; }
        }

        // Access anywhere else in Project as..
        App.Current.<Global_Variable> .. 

Two:

Considering using the Silverlight Windows Phone Toolkit in your project? If not, you should definitely take a look here .. this Toolkit is built by MSFT employees, notably the famous Jeff Wilcox. So, you can absolutely trust it & may be should not try to reinvent the wheel with features the Toolkit already provides.

Now, two of the most common controls used from the Toolkit are the DatePicker & TimePicker; exactly what I was using it for. Now these two controls allow the user to pick a Date/Time in the default Windows Phone scrolling list fashion & essentially bring back a DateTime selection. Most of us will simply download the binaries of the Toolkit and add a reference to it in our projects to start using these controls. I did the same; but when I threw in the Date/Time Picker controls in my project, the full-screen pop-up looked like this:

Datepicker With Missing Icons

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Notice the Accept/Cancel icons at the bottom are missing? Now, these are two standard icons that are a part of the official ApplicationBar Icon pack as found here and also downloaded when you got the Toolkit. They are not showing up on screen because the Toolkit code is not finding it where it’s looking for in your project structure. So, unless you want to get the source code for the Toolkit and change the configuration of where it looks for the icons, this is what is needed:

Toolkit.Content

 

 

 

 

As you can notice, the Toolkit code expects the icons to be in a special folder & with the above names. As always, do not forget to mark the icon images as “Content“.

That’s it! Hope this was helpful.

Adios!

Advertisements
Comments
  1. […] Read original post by Samidip Basu at Windows Phone Love & .NET Ramblings […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s