BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

SubMenus in C++

14 Apr 2021, 15:30

Hello. Im thinking about logic of subtabs menus. I have some main tabs and each generate 1 subtabs below, each 2, each 5 and so on... And the trick is those subtabs maybe would generate another subtabs so I don't know how to handle it. Should I create every time independed xaml file and .cpp class? It take long to write this stuff for every tab/subtab. How do u think it should be done?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: SubMenus in C++

14 Apr 2021, 19:55

What control do you need, a ContextMenu with sub menu options, or a TabControl with tabs?

My recommendation is you use a MVVM approach with data binding and data templates. In the case of MenuItems you will need to use HierarchicalDataTemplates so you can have any number of sub levels depending on the data. In the case of a TabControl you should use DataTemplates that contain a TabControl again if you want sub levels.

In both cases the viewmodel of an option exposes an ObservableCollection for the children options that you can bind to the ItemsSource property (of the HierarchicalDataTemplate or the inner TabControl).

Who is online

Users browsing this forum: No registered users and 72 guests