Best practise for RibbonBar and implementation #281
Replies: 1 comment 1 reply
-
What you've done sounds fairly sensible, although I'd use a property in the VM and a binding in the View rather than an event. I'd also probably use an attached behavior to move logic out of the View's codebehind. I might also have a play with trying to avoid passing the view-specific buttons through the ViewModels, and either have the shell view bind directly into the child view, or use an attached behavior. I might also be tempted to define a UserControl subclass which has a property containing the View-specific buttons, rather than making them resources. Or perhaps use an attached property instead. I'm not at a computer at the moment: I'll have a play when I am.
Set |
Beta Was this translation helpful? Give feedback.
-
Hello,
after developing for years with WPF, Stylet come across for me and I felt in love with it! Thank you so much for you effort and that I can use it. When I find a spot where I could help, I'll be happy to contribute to give a little bit back to the community.
One thing I don't find in the wiki or here at discussion sector is the best practise for following situation. I think is situation is common but may be I don't use the correct search terms for it.
I have a shell view where I introduce a ribbon bar. Here all common buttons are visible and I can call sub functions which are implemented as sub view models. This sub view models have specific buttons / commands which I like to offer as context tabs at the ribbon bar. To achieve this, I implemented a event send by ShellViewModel to ShellView. The ShellViewModel tries to read from ActiveItem.View resources by a magic key the RibbonTabs and forward those by event to ShellView code-behind. Here I change the ribbon bar and add the ribbon tabs from the current sub view.
Is that a good approach? Do you have a better way?
However, when I click on the button at contextual tabs, the actions are expected at ShellViewModel even the DataContext is set correctly at tab level. How do I say Stylet to look for actions at sub view model with guard methods?
Thank you for your tips and great work again!
Beta Was this translation helpful? Give feedback.
All reactions