SubMenus in C++
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?
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: SubMenus in C++
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).
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: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 22 guests