开发者

Windows 7 PHone - KeyNotFoundException

In my WP7 app, I'm attempting to navigate from one screen to the other. The 1st screen contains data that I want to pass to the second string.

On my button click event I have the following code (updated):

string data = "blahblahblah";

NavigationService.Navigate(new Uri(String.Format("/popup.xaml?param={0}", Uri.EscapeDataString(data)), UriKind.Relative));

On popup.xaml I have开发者_StackOverflow社区 the following:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    MessageBox.Show(NavigationContext.QueryString["param"]);
}

When I press the button it breaks on the NavigationContext.QueryString["param"] stating that there is a KeyNotFoundException

What am I doing incorrectly?


You're not using "=" and you're not encoding the value. Currently the query part is just

paramblah blah blah

It should be

param=blah%20blah%20blah

You can include the = directly, and I tend to use Uri.EscapeDataString for the value part.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜