top button
Flag Notify
Site Registration

Explain WindowsPhone Application/Global variable?

+3 votes
383 views
Explain WindowsPhone Application/Global variable?
posted Jul 2, 2015 by Karthi Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

We can set a variable that can be accessed on all pages of a Windows Phone App

Step1:

App.xaml.cs

public partial class App : Application
   {
        public string sName { get; set; }
   }

Step2:

Now access application variable "sName" in entire application like this

(App.Current as App).sName = "Test value";//set value                                                               
string myvalue=(App.Current as App).sName;//get value
answer Jul 3, 2015 by Jdk
...