user2000819
user2000819

Reputation: 1

use a variable from a page in another one

I'm creating an app for Windows store using C#. I need to pass a string variable to another page. I have already tried using this variable as an input parameter of the page where the variable is going to be used, like this:

In the page where the variable was created:

this.Frame.Navigate(typeof(MainMenu(Variable)));

In the page where the variable is going to be used:

public PageName(string Variable)
{
   this.InitializeComponent();
}

so, something like winforms, obviously doesn't work to windows store

Upvotes: 0

Views: 1562

Answers (3)

granaker
granaker

Reputation: 1328

Have a look at this page under "Passing information between pages" for example code.

Upvotes: 1

Dimi Takis
Dimi Takis

Reputation: 4949

You need to work with the following event to get the value of the variable out

OnNavigatedTo

Here is the corresponding link on MSDN

Upvotes: 0

polkduran
polkduran

Reputation: 2551

You can pass a parameter to the Navigate method.

this.Frame.Navigate(typeof(MainMenu),yourVariable);

and in your MainMenu page you can find your "navigation data" in the OnNavigateTo (virtual) method.

hope this help.

Regards

[Edit] Take a look at this exemple Quickstart: Navigating between pages

Upvotes: 3

Related Questions