Replies: 1 comment
-
|
Don't use the raw text in the files in the /SampleCode folder, they're read by the sample app and edited dynamically which is why they have things like However, I will note there needs to be an example with the Frame control, so I'll add that as part of my refactoring coming up. To use <ui:NavigationView Name="MyNavigationView">
<!-- Set the frame as the content of the NavigationView -->
<ui:Frame Name="MyFrameControl" />
</ui:NavigationView>In code behind, handle navigation // Handle invoking an NavigationViewItem (clicking on it, for example)
MyNavigationView.ItemInvoked += OnNavItemInvoked;
// Handle pressing the back button of the NavigationView (if you want it enabled)
MyNavigationView.BackRequested += OnBackRequested;
private void OnNavItemInvoked(object sender, NavigationViewItemInvokedEventArgs e)
{
// Get the invoked NavigationViewItem
var nvi = e.InvokedItemContainer as NavigationViewItem;
// Get the invoked item (if using MVVM, otherwise its the same as the invoked container)
var item = e.InvokedItem;
// From the item selected, decide where you want to navigate to:
// You can use the Tag property (or your view model from 'item' to determine the page to go to next
if (nvi.Tag is Type t && t == typeof(HomePage))
{
// Call the Navigate method on Frame to navigate to the page you want
MyFrame.Navigate(typeof(HomePage));
}
}
private void OnNavigationViewBackRequested(object sender, NavigationViewBackRequestedEventArgs e)
{
MyFrame.GoBack();
}Also these controls come from WinUI, so you can always check their documentation too - the examples should work the same.
I'm not sure what you mean by "Command button" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Its very hard to understand how to navigare throuth Frame. Why there is not any Command button please ? This is very strange and it is so confusing. can any one please simple make some example how navigation works please. I did check samples but its all about mess i could not find it answer just xaml samples without any explnation how to click and navigate.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions