【问题标题】:Navigation and Query parameter to another page Windows Phone 8.1导航和查询参数到另一个页面 Windows Phone 8.1
【发布时间】:2015-05-21 17:32:18
【问题描述】:

我有 Windows Phone 8.1 应用程序,我需要使用参数从主页导航到“pizdec”页面。

我有一个鳕鱼,它可以在 WP8.0 中完成,但是如何用代码 WP8.1 重写它,我不知道。

示例:

private void listbox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
   {
     if (listbox1.SelectedItem != null)
     {
        var file = listbox1.SelectedItem as StorageFile;
        NavigationService.Navigate(new Uri("/pizdec.xaml?filename=" + file.Name, UriKind.Relative));
        listbox1.SelectedItem = null;
     }

我知道我需要使用 this.Frame.Navigate() ,但我不明白如何将其重写为 8.1

来自pizdec.xaml的代码:

protected override void OnNavigatedTo(NavigationEventArgs e)
   {
      base.OnNavigatedTo(e);
      string filename;

    if(NavigationContext.QueryString.TryGetValue("filename",out filename))
    {
        DisplayFile(filename);
    }

还有NavigationContext,在 8.1 中没有

请帮忙

【问题讨论】:

标签: c# windows-phone-8.1


【解决方案1】:

你使用以下,

Frame.Navigate(typeof(pizdec), param); //a Windows app syntax. param is parameters you want to pass to pizdec.xaml

您可以通过如下方式访问下一页中的参数,

string filename = e.NavigationParameter as string;

Microsoft 正在尝试使 Windows 和 windows phone 应用程序的语法相似,因此进行了更改。更多信息here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多