我有一個應用程序應該將登錄用戶重定向到特定頁面。從Silverlight子頁導航
我的問題是,我得到一個錯誤信息關閉子窗口::: MainPage mp =(MainPage)Application.Current.RootVisual;在這種情況下我如何重定向?
/// <summary>
/// Navigate to page that user is most likely to use.
/// </summary>
private static void NavigateToUserPage()
{
// Get logged in Role
User user = WebContext.Current.User;
// Count if collection > 1
List<string> roles = new List<string>(user.Roles);
if (roles.Count > 1)
{
// goto roles pages to select the user role
}
else
{
switch (roles[0])
{
case "SiteAdmin":
Uri uriSiteAdmin = new Uri("OwnerOccupier", UriKind.Relative);
MainPage mp = (MainPage)Application.Current.RootVisual;
mp.ContentFrame.Navigate(uriSiteAdmin);
break;
case "OwnerOccupier":
Uri uriOwner = new Uri("OwnerOccupier", UriKind.Relative);
MainPage p = (MainPage)Application.Current.RootVisual;
p.ContentFrame.Navigate(uriOwner);
break;
default:
break;
}
}
}
如果您希望獲得一些有關出現錯誤的詳細信息,那麼通常會提供幫助。 – AnthonyWJones 2011-01-06 12:54:32