Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

XAML - Storing and accessing global constants - How?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DanThMan - 09 Feb 2008 21:37 GMT
This seems like it should be so simple, but I'm just not having much
luck with this. I have an constant in my App.xaml.cs file (i.e., code-
behind) called Name.

public const string Name = "Dan";

And now, I want a Label on my Window1.xaml page that shows the Name. I
will eventually want to show the same Name on other pages. So, I want
to be able to access (bind to?) this global constant from anywhere in
the project.

I've read up on x:Static, static resources, and different ways of
binding data to XAML properties, but so far, no combination of these
techniques seems to work. What is the best way to store and access
constants in XAML that apply to the whole project?

Thanks for you help,

-Dan
Nicholas Paldino [.NET/C# MVP] - 11 Feb 2008 17:13 GMT
Dan,

   Take a look at this blog entry from Karsten Januszewski:

http://blogs.msdn.com/karstenj/archive/2005/07/15/439167.aspx

   It addresses how to access constants in XAML.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> This seems like it should be so simple, but I'm just not having much
> luck with this. I have an constant in my App.xaml.cs file (i.e., code-
[quoted text clipped - 15 lines]
>
> -Dan
DanThMan - 11 Feb 2008 18:17 GMT
On Feb 11, 9:13 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> Dan,
>
[quoted text clipped - 27 lines]
>
> > -Dan

Perfect! Thank you!

-Dan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.