{
// Load the main control
this.RootVisual = new Page1();
// 或者加載Page2
//this.RootVisual = new Page2();
}
如果要判斷,可以通過StartupEventArgs對象的InitParams集合,這是一個鍵/值對集合,向它傳入初始化參數。方法如下:
這樣在App.xaml.cs中就可以檢查值了:
{
this.RootVisual = new Page1();
}
else
{
switch (e.InitParams["Role"])
{
case "User":
this.RootVisual = new Page1();
break;
case "Admin":
this.RootVisual = new Page2();
break;
default:
throw new Exception("缺少權限信息");
}
}