Windows Phone 7 String Variables

Like the way Android does it.

Page 1 of 1

2 Replies - 20639 Views - Last Post: 19 September 2010 - 06:41 PM

#1 bastecklein   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 08-October 09

Windows Phone 7 String Variables

Posted 15 September 2010 - 03:48 PM

I have been developing apps for the Android environment and with Android, you are able to have a strings xml file that can house commonly used variables. I am now trying to make a Windows Phone 7 application and do something similar, but I can not figure it out for the life of me. I tried making a resx file and also a custom xml file, but I am not able to read from either of them within my program. I have searched google for how to do this, but either I do not know what to search for, or there is no information out there. If anybody has any ideas I would be forever greatful.

Is This A Good Question/Topic? 0
  • +

Replies To: Windows Phone 7 String Variables

#2 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Windows Phone 7 String Variables

Posted 16 September 2010 - 06:53 AM

You can do this in the App.xaml file. In the Application.Resources node(if it's not there, create it), you would do this..

<Application.Resources>
   <clr:String x:Key="MyHeading">Some Text</clr:String>
</Application.Resources>



then on your screen, you might do something like this...

<TextBlock x:Name="HeadingTextBlock" Text="{StaticResource MyHeading}" />



The textbox would now have the text of "Some Text".
Was This Post Helpful? 3
  • +
  • -

#3 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Windows Phone 7 String Variables

Posted 19 September 2010 - 06:41 PM

That's pretty nifty. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1