Page 2 of 2

Re: Keyboard Navigation - how to make a tree of focusable input?

Posted: 05 May 2021, 14:43
by BartekW
What if I would have 10 menus (whole menu with submenus), can I have 1 ViewModel for them or ViewModel per menu?

Re: Keyboard Navigation - how to make a tree of focusable input?

Posted: 05 May 2021, 20:24
by KeldorKatarn
You want to databind a ContentControl to the a property on the ViewModel. That property will change to whatever should be displayed. Then you define the UserControls as DataTemplates for these types.

https://stackoverflow.com/questions/573 ... pplication

Re: Keyboard Navigation - how to make a tree of focusable input?

Posted: 06 May 2021, 10:41
by BartekW
You want to databind a ContentControl to the a property on the ViewModel. That property will change to whatever should be displayed. Then you define the UserControls as DataTemplates for these types.

https://stackoverflow.com/questions/573 ... pplication
Yee I understand so for my example
-1MainTab
*1SubTab <- generate content in ControlContent

-2MainTab
*1SubTab <- generate content in ControlContent
*2SubTab <- generate content in ControlContent

I will have here 3 view models"
1) for main view model (1MainTab and 2MainTab)
2) for 1MainTab's SubTab's, maybe i will here here more subtabs
3) for 2MainTab's SubTab's

How u think it to make it reusable for another menus?

Re: Keyboard Navigation - how to make a tree of focusable input?

Posted: 06 May 2021, 16:44
by KeldorKatarn
It's really hard to describe all the basics here in a short post. I think you need to read up on how the MVVM pattern works. You're trying to implement an advanced navigation without understanding the basics of the architecture yet. I don't think this is the best place for that. Maybe try it in a normal WPF application first?

Here's a tutorial on how to achive navigation like this: