Windows 8 User Control Navigation issue

帅比萌擦擦* 提交于 2019-12-12 05:07:36

问题


My requirement is that I have to add one common usercontrol in all my pages. The usercontrol will have 5 buttons. When user presses on one button navigation should happen to that button related page. I'm handling same thing in windows phone with following code:

(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(
                        new Uri(PageUrls.INCOMEEXPENCE_PAGE, UriKind.Relative));

Now I want this in my window 8 application. Please help me on this.


回答1:


It will be like this

private void btnMyPage_Click(object sender, RoutedEventArgs e)
{
    Frame.Navigate(typeof(MyPage),YOUR_PARAMETER);
}

Where MyPage is XAML page and YOUR_PARAMETER is object parameter if you want to pass some data while navigating, it's optional. You can access that parameter in OnNavigatedTo event with e.Parameter.

Please check this article for more info : WinRT XAML Navigating from Page to Page: How it differs from Windows Phone 7

EDIT 1 :

As per your comment, you want master page like feature in you app. So I would suggest you to check this : Windows 8 XAML Tips - Master Pages.

Moreover, I recommend you to check Windows Store Apps samples. It has also UI like you want, it has header & footer and the various scenarios are displayed in center.



来源:https://stackoverflow.com/questions/15758375/windows-8-user-control-navigation-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!