I have an application that has a top level navigation menu which consists of series of buttons within a stackpanel. When a user clicks on a button the view model processes the command and updates the value of CurrentView (type UserControl). The CurrentView is bound to the element ContentControl as below.
<ContentControl Content="{Binding CurrentView}" />
I want the ‘menu’ to keep track of where the user is so that I can change the foreground of the navigation buttons, so users know where they are. What is the best way to do this? Should I wrap this ‘menu’ into a control?
Some of the views passed to the ContentControl will have their own sub menus. These submenus work in the same way, and I would like to change the foreground and background for these.
Most of what you are talking about here is typically done by using a Frame, and Navigation with Pages of content. Is there a specific reason you are not using this?
For Example:
And then within your page:
If you don’t want to use pages, and want to use controls, you can do that, but you will have to provide the tracking manually. I would recommend using a view model just for your navigation, which can persist some data itself.