How to pass more than one parameter for frame navigation in Metro Style applications?

I am creating a Metro Style application for Win8 that requires passing two values โ€‹โ€‹of a text block when navigating frames. It works for one parameter, but it does not work for two parameters. Please help! I tried the following: this.Frame.Navigate (typeof (SecondPage), textblock1.Text + textblock2.Text);

I do not see any error, but it does not work.

+7
source share
3 answers

Create a new class with 2 properties and set the properties for the values โ€‹โ€‹of the text block. Then you pass this object when navigating.

Create a payload class:

public class Payload { public string text1 { get;set;} public string text2 { get;set;} } 

Then fill in the payload class:

 Payload payload = new Payload(); payload.text1 = textblock1.Text; payload.text2 = textblock2.Text; 

Then, when you call Navigate, pass your payload instance as follows:

 this.Frame.Navigate(typeof(SecondPage),payload); 
+8
source

I took such a dictionary object.

 Dictionary<string, string> newDictionary = new Dictionary<string, string>(); newDictionary.Add("time", itemObj.repTime); newDictionary.Add("message", itemObj.repMessage); Frame.Navigate(typeof(ViewDetails),newDictionary); 

On the ViewDetails.xaml.cs page, I got data like this,

 protected override void OnNavigatedTo(NavigationEventArgs e) { Dictionary<string, string> myDictionary = new Dictionary<string, string>(); myDictionary = e.Parameter as Dictionary<string, string>; timeTB.Text = myDictionary["time"].ToString(); messageTB.Text = myDictionary["message"].ToString(); } 
+1
source

All Articles