简体   繁体   English

从NavigationContext获取数据时出错

[英]Error while getting data from NavigationContext

I am creating a Reminder app using C# in Visual Studio 2013. One of the pages is for launching the notification. 我正在Visual Studio 2013中使用C#创建一个提醒应用程序。其中一个页面用于启动通知。

My code is : 我的代码是:

protected override void OnNavigatedTo(NavigationEventArgs e)
    {

       base.OnNavigatedTo(e);

       string Combobox = "";
       string Content = "";

     NavigationContext.QueryString.TryGetValue("param1", out Combobox);

     NavigationContext.QueryString.TryGetValue("param2", out Content);

     param1TextBlock.Text = Combobox;
     param2TextBlock.Text = Content;     

    }

But the errors occur in this part : 但是错误发生在这部分:

     NavigationContext.QueryString.TryGetValue("param1", out Combobox);

     NavigationContext.QueryString.TryGetValue("param2", out Content);

The Error is : 错误是:

Error 1 An object reference is required for the non-static field, method, or property 'System.Windows.Navigation.NavigationContext.QueryString.get' 错误1非静态字段,方法或属性'System.Windows.Navigation.NavigationContext.QueryString.get'需要对象引用

Any idea? 任何想法?

您很可能已经创建了“ Windows Phone”应用程序项目,而您需要创建“ Windows Phone Silverlight”才能访问NavigationContext类。

List<string> MyStringsList = new List<string>();

this.Frame.Navigate(typeof(PageName),MyStringsList);

this code is used for navigation with parameters, you can get these parameters at the navigated to page in OnNavigatedTo event : 此代码用于带参数的导航,您可以在OnNavigatedTo事件的“导航至”页面上获取这些参数:

protected override void OnNavigatedTo(NavigationEventArgs e)
{

   List<string> MyRecievedParameters = e.Parameter as List<string>;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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