简体   繁体   中英

Key not found exception pivot wp7

On my detail.xaml

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    this.PageTitle.Text = NavigationContext.QueryString["lineone"];
    this.Contents.Text = NavigationContext.QueryString["linethree"];
    //populate book text control here
}

but when i enter lineone in place of line three it works fine except it shows the data of line one in the contents section.

I am using default pivot based layout for windows phone 7

If you attempt to access a key that isn't found, you get a exception.

So instead of NavigationContext.QueryString["key"] you should use NavigationContext.QueryString.TryGetValue("key")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM