Thursday, December 24, 2009

Silverlight How To Pass Values Between Pages or Forms

In App.xaml.cs have declared some application level variables as follows,

private string valueToPass

public string valTo
{
    get
    {
        return valueToPass;
    }
    
    set
    {
        valueToPass = value;
    }
}

page1.xaml.cs

App ap = (App)Application.Current;
ap.valueToPass = "YourValue";


page2.xaml.cs

App ap = (App)Application.Current;
messageBox.show(ap.valueToPass);

No comments: