Question

I have a question concerning Josh Smith's famous demo app on MVVM.

I try building a "real" application around it to learn WPF.

He creates this CommandsList in the MainWindowViewModel containing 2 Commands (create new and view all customers). This list is readonly (why? any particular reason?). I thougt it would be nice to add and remove some commands, depending on the workspace that is currently selected. Like edit or delete a customer when it has the focus and so on.

How would I accomplish this?! Can I just make it a normal list and add commands? Or bind the Commands-View to a commands list of the selected workspace instead of the MainWindow? How? Any other ways? Please share your ideas!

Thank you very much!

Was it helpful?

Solution

I write an article about defining the commands in the viewmodel and how you can then use all the possibilities of databinding to show your commands.

One of the possibilities mentioned was to

define a filtered version of the command list “local menu commands” for direct use in the view

Something similar is what I think you should do in your situation: write some filtered version of the command list and change it depending on your state.

The article also contains a link to a very simple demo application that shows only how this works so I think it could help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top