Reputation: 1183
In my application I need some variables on almost all the pages so I declared them in Application.xaml like
<sys:String x:key="First">First</sys:String>
and on one page I change the value in code like
Resources["First"] = "This is First";
on the second page when I call the variable like
String f = (string)this.TryFindResource("First");
MessageBox.Show(f);
the out put is "First" and not "This is First". I also tried like.
Application.Current.Properties["First"]
Upvotes: 0
Views: 200
Reputation: 16648
You need to use Binding for such scenarios.
If you want the value to be globally available, make it static and then access it like:
<TextBlock Text="{x:Static local:MyGlobalClass.First}" />
Upvotes: 1