0

Is there a way in a NavigationView in UWP to have multiple "Views" for NavigationViewMenuItems? The concept would be to have Categories or Folders as MenuItems, and when clicked or the NavigationViewMenuItems would slide out to the left and show the contents of the folder or category. Then when navigating back out of the folder, the folder and categories list would slide in from the left again. I know I can change the NavigationView.MenuItemsSource in C#, but I'd like to instead have this done primarily in XAML. I've tried numerous ways to do this, but can't seem to find a way that works.

I don't really have any code to demonstrate this, as this is a whole concept issue rather than a single bug that isn't working. I have searched everywhere, and have found numerous articles/links about loading different views into NavigationView.Content, but nothing of changing the MenuItems portion.

Does anyone have any ideas on how to achieve this, or a link to a tutorial I could follow? I can't imagine that this has never been done before, this seems like such a common-sense UI interface.

Keven M
  • 972
  • 17
  • 47
  • Have you tried overriding the default style for the NavigationView? – DotNetRussell Mar 27 '19 at 16:11
  • No, I wasn't even thinking along those lines....I know how to do a custom style, but how would that work in having multiple menu views? – Keven M Mar 27 '19 at 16:15
  • So, I'm pretty sure this isn't a feature of NavigationView, I could be wrong. So what I would do is crack open the navigationview style, create my own style based on it and build in the features you want. I'd then opensource it and share it on twitter #UWP :-) – DotNetRussell Mar 27 '19 at 16:17
  • So essentially build a Templated Control that would work like this. Yeah, I could do that... . I'm truly surprised this isn't a built-in feature though, I have numerous Android apps that use this exact control. – Keven M Mar 27 '19 at 16:20
  • Yeah, i have some examples of this in my UWP lib if you need help getting started https://github.com/DotNetRussell/UWPLibrary/tree/master/BasecodeLibrary/BasecodeLibrary – DotNetRussell Mar 27 '19 at 16:22
  • 1
    Thanks, I'll definitely take a look at it! – Keven M Mar 27 '19 at 16:23

1 Answers1

0

What you need actually is a Tree Navigator. The UWP has no such a built-in control for us. You could use the third-party control like Syncfusion TreeNavigator.

See the code sample on GitHub: https://github.com/syncfusion/uwp-demos/tree/master/Navigation

Bite
  • 302
  • 1
  • 10
  • I just installed it, and that is basically what I'm looking for, thank you! Do you happen to know if it's still modifiable though, like could I still build a custom style or even Templated Control based off of it? There are some things I'd prefer to change... – Keven M Mar 28 '19 at 02:37
  • Check its document. – Bite Mar 28 '19 at 03:03
  • I was looking at it, but I've never used a commercial (non-free/open source) library, so I don't know how or if that would work. – Keven M Mar 28 '19 at 03:05
  • I played around with this a little more, and it is possible to restyle the Tree Navigator, but I also discovered a negative to this control. It can't be used within `NavigationView.MenuItems` without losing the functionality of being able to navigate to subfolders. If I use just the TreeNavigator, then I lose the `NavigationView` features of having both a Pane and Frame layout. This basically puts me back at the initial issue. So far I'm thinking the best approach is to follow the suggestion of @anthony-russell and Template the `NavigationView`. – Keven M Mar 28 '19 at 12:58