【问题标题】:Passing String to next XAML Page将字符串传递到下一个 XAML 页面
【发布时间】:2013-03-08 12:59:11
【问题描述】:

我正在使用 C# 和 XAML 开发 Windows 应用商店应用程序。从一页移动到另一页时,我想传递一个字符串。例如,

 private void filterData_Click(object sender, RoutedEventArgs e)
    {
           string str="mydata";
           this.Frame.Navigate(typeof(QualityRecordsResults));
    }

我需要 QualityRecordsResults.xaml.cs 文件中的这个 str 值。

【问题讨论】:

    标签: c# xaml windows-store-apps


    【解决方案1】:

    您可以使用Navigate 方法的重载将字符串传递给您的视图。

    string str="mydata";
    this.Frame.Navigate(typeof(QualityRecordsResults), mydata);
    

    【讨论】:

    • 你的意思是,this.Frame.Navigate(typeof(QualityRecordsResults), "mydata");如果是这样,我怎样才能得到 QualityRecordsResults.xaml.cs 中的第二个参数?
    • @Ramesh 是的,这就是我的意思
    • 参数存储在NavigationEventArgs 中,传递给您的 QualityRecordsResults 中的 Navigated-EventHandler。
    • 是的。使用 navigationParameter.ToString();我能够得到字符串。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    相关资源
    最近更新 更多