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 2 9802
Dan,
Take a look at this blog entry from Karsten Januszewski: http://blogs.msdn.com/karstenj/archi...15/439167.aspx
It addresses how to access constants in XAML.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"DanThMan" <da******@cox.netwrote in message
news:3b**********************************@e4g2000h sg.googlegroups.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-
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
On Feb 11, 9:13 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Dan,
Take a look at this blog entry from Karsten Januszewski:
http://blogs.msdn.com/karstenj/archi...15/439167.aspx
It addresses how to access constants in XAML.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"DanThMan" <danth...@cox.netwrote in message
news:3b**********************************@e4g2000h sg.googlegroups.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-
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
Perfect! Thank you!
-Dan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Leigh Riley |
last post by:
Hi,
Can someone tell me if the following is possible?
I have a file containing some STATIC variables, and some functions e.g.
-------------------------------------------------...
|
by: Matt |
last post by:
Greetings,
What are people's thoughts on global variables in C++?
Why are we taught not to use them in programming?
Is it true that if you are running two copies of the C program one
copy can...
|
by: 2obvious |
last post by:
I've been trying to create read-only global variables by creating
constants (Const) in my global.asa, but I can't seem to reference them.
Sticking them in an include works fine, but it seems more...
|
by: Daniel Bass |
last post by:
how do i declare a global variable in c#.net? it's like it want's everything
in classes... there are times when globals are good, like having constants
in a program which apply to several...
|
by: Amadelle |
last post by:
Hi all and thanks again in advance,
What is the best way of defining global constants in a C# application? (A
windows application with no windows forms - basically a set of classes).
Would it be...
|
by: Marty |
last post by:
Hi,
I'm new to C#, I used to code in VB.NET. Where is the best place to
declare all my constants and global objects in my C# project to have
them accessible globally?
I have an event logger...
|
by: Demetri |
last post by:
Unfortunately, where I work it is forbidden to use stored procedures. I know,
I know...it's pretty stupid. But I can not change that.
Anyway, currently we have our sql stored in an embedded resx...
|
by: dnn |
last post by:
How can I access dynamically loaded variables?
I am trying to load an external javascript file dynamically and then
access its variables. The script is loaded by the onload handler.
The code...
|
by: lazy |
last post by:
hi,
I have some constants defined in a php script say config.php.
I want to use the variables there defined in other scripts.
couple of questions regd that:
1. Is there an alternative to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |