The Curious “Today” Button

[UPDATED: This article was meant to share a quick hack that I created.  I am not endorsing this as a best practice that you should incorporate into your applications.  I’m offering it as an option to those of you building apps that only use the English language.]

Yesterday, I was working on a Windows Phone application that is very date-centric.  I show the user a list of events for a specific day, and the page always loads data for “today” by default.  They can always change it (I’m using a DatePicker for that), but I wanted to give them an easy way to return to whatever “today” may be.

I’d seen this before, in the Calendar app that comes on Windows Phone by default.  It looks like this:

As you can see, there is a “today” button in the ApplicationBar.  (In the image, today must be July 7th.)  Anyways, I did some investigation, and came to a conclusion that either that image is being generated on the fly, or they’ve included 366 images in their project, to accommodate every possible month/date combination.

Since I’ve never done any dynamic image generation before, it seemed like more work that I was prepared to accomplish in the short timeline I had to finish this application.  So, I went ahead and created the 366 images that are necessary to make this functionality happen.

To change the IconUri property of an ApplicationBarIconButton, you just need this one line of code:

((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IconUri = new Uri("/icons/dates/" + DateTime.Now.Month + "-" + DateTime.Now.Day + ".png", UriKind.Relative);

Finally, you’re probably interested in downloading this set of images, so you don’t have to spend the countless hours (it was less than 2) I spent creating them.  So, here they are:


Or, if that’s not convenient, you can download the entire collection of Windows Phone Date Icons in a ZIP file here.

These images are completely free to use, I only ask that you comment here on how you used them.  Fair?

7 thoughts on “The Curious “Today” Button

  1. While it’s great that you did that, I wish MS had just made it so the ApplicationBar could accomodate XAML icons. I do my drawing in Illustrator since I’m very experienced with it, then import them into Blend. So at least for Blend owners it’s no problem. I could see making a control and just changing the date programmatically.

  2. hi,
    i really liked your 31-days series but in my opinion this is a really bad approach. Currently i have an app supporting 5 different languages. So i have to add these icons in all different language formats. Sorry – no go. It’s really easy to draw to a .png and create the image dynamically (i am doing this for creating a live tile)

  3. I recognize that this is not an ideal approach for those of you supporting multiple languages, but it is a viable option for those applications that only support English.

    As I stated in my post, creating dynamic images is probably the best approach (and would support your multiple language scenarios), but for the crunched deadline I was under (for an English app), it was sufficient.

    I just figured I would share the results of my work, I was not endorsing this as a best practice.

    Geert van der Cruijsen has written an excellent tutorial on how to accomplish this…check it out.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s