WPF导航的现代UI

时间:2013-12-01 20:39:33

标签: c# wpf navigation modern-ui

如何在页面之间传递参数?我试图添加参数页面uri但它不起作用因为我不能在用户控件上使用onNavigatedTo事件。 请帮忙

2 个答案:

答案 0 :(得分:2)

您必须使用One Fragment Navigation。

public void OnFragmentNavigation(FragmentNavigationEventArgs e)
{
  DoYourStuff(e.Fragment)
}

e.Fragment包含URI中#之外的所有内容。例如,使用

NavigationCommands.GoToPage.Execute("/Pages/CustomerPage.xaml#CustomerID=12345", this);

e.Fragment将是“CustomerID = 12345”

答案 1 :(得分:0)

看起来您来自显示网页世界的客户端浏览器。使用WPF,您拥有该应用程序!您可以在导航之前或之后在新页面上设置值,使用构造函数传递它,或者从两个页面都可访问的位置访问它。听起来这个参数是页面的一个参数,所以我会在这种情况下用构造函数传递它:

public class APage : Page
{
    private object myVar; // use whatever Type you want

    public APage
    {
        InitializeComponent();
    }

    public APage(object arg) : this()
    { 
        this.myVar = args;
    }
}