问题
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