Saturday, September 4, 2010

Windows Phone 7 Quick Tip #1 – Use App.Resources for your Application Title

On most screens within your Windows Phone 7 application you might need to display your application name.  This might be in a simple page or one that contains a Pivot or Panorama.

Standard Page

image

Pivot Page

image

Panorama Page

image

With the XAML that gets generated you can enter your application name for the respective page types as:

image

image 

image

Notice how the same text is entered for each title as a string literal?

A better solution is to use a string resource.  To create a string resource, add the following to your Application.Resources node within the App.xaml file.

image

Then everywhere you need to use your application name you can use the following syntax

image

-twb

4 comments:

  1. Hi, thanks for the blog, I really do like what/how you've done this, very DRY. But when I do exactly as you did (with very simple, out of the box, WP7 template with current tools) I get "'clr' is an undeclared prefix"

    Any suggestions?

    ReplyDelete
  2. AHA! I was able to figure out I was missing this namespace which isn't/wasn't part of the default template.

    xmlns:clr="clr-namespace:System;assembly=mscorlib"

    ReplyDelete
  3. Thank you for this, I just blogged about it (and of course gave you credit for the IP and inspiration! :>)

    http://www.pchenry.com/Home/tabid/36/EntryID/340/Default.aspx

    ReplyDelete
  4. Great Article
    android based projects

    Java Training in Chennai

    FInal Year Project Centers in Chennai

    Java Training in Chennai

    projects for cse

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete