Reply to comment

Responsibilities

I would be interested in seeing your solution. Could you post it to GitHub, or your blog?

I haven't tried to do this before. I've considered the context menu to be the responsibility of the view. But you make a good point about using the same context menus across platforms. Maybe it does belong in the view model after all. If you think about it, it's not so different than putting ICommands in the view model. It's just another manifestation of the Command Pattern.

It seems like you are pretty close to solving the ordering and separation problems. Just honor the order in which the view model returns the IMenuItemVM objects from the event (WinForms) or property (XAML). And then move the methods from IMenuItem to a derived interface IMenuItemCommand. Define another derived IMenuItemSeparator, and perhaps even an IMenuItemSubMenu.

I stopped using the term Presentation Model (coined by Martin Fowler) and started using View Model (coined by Josh Smith). The later has gained wider acceptance. I have similarly switched from Navigation Model to Selection Model to describe the pattern presented here. Navigation Model caused confusion when it was not used for page navigation.

Reply

By submitting this form, you accept the Mollom privacy policy.