{
// 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("缺少权限信息");
}
}