简体   繁体   中英

How does navigation in MVVM UWP application work?

This is basically the lightweight question. I recently started migrating myself from WPF to UWP and faced some issues with differences between those two platforms. And one of them is navigation, so to say. I would like to ask you, guys about major navigation approaches in UWP applications with MVVM in-behind.

In WPF I had a general Storage of all the ViewModels, and the ContentControl took the CurrentViewModel value from that storage and then showed the corresponding View. Here, I guess, I can do it as well, but I would like to approach it with UWP Navigating Services. How do I do that?

I can do it as well, but I would like to approach it with UWP Navigating Services. How do I do that?

Sure, you could Use NavigationService to implement this feature, and u could get current root frame with Window.Current.Content as Frame; and bind the NavigationViewItem with Page type, when the item selected, you could get current page type and call NavigationService to navigate page that you want.

For getting the complete code sample, please install Template Studio for UWP , and make UWP project with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM