I am building a Metro Style App for Win8 which requires to pass two textblock values on frame navigation. For one parameter, it works but for two parameters its not working. Please help! I have tried like the following: this.Frame.Navigate(typeof(SecondPage),textblock1.Text + textblock2.Text);
I doesn't show any error but its not working.
Create a new class with 2 properties and set the properties to the textblock values. Then you pass this object when you navigate.
Create the payload class:
public class Payload
{
public string text1 { get;set;}
public string text2 { get;set;}
}
Then populate the payload class:
Payload payload = new Payload();
payload.text1 = textblock1.Text;
payload.text2 = textblock2.Text;
Then when you call Navigate pass your instance of payload like this:
this.Frame.Navigate(typeof(SecondPage),payload);
I have taken a dictionary object like this.
Dictionary<string, string> newDictionary = new Dictionary<string, string>();
newDictionary.Add("time", itemObj.repTime);
newDictionary.Add("message", itemObj.repMessage);
Frame.Navigate(typeof(ViewDetails),newDictionary);
On ViewDetails.xaml.cs page I had retrieved the 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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With