in my WPF application (MVVM pattern) I'm trying to handle events from several UCs (call it children) in a main UC, call it parent (kind of layout manager). Every child has an event to tell the parent closing the child. Looks like that:
ParentView
|
- ChildView
|
- ChildView
|
- etc.
Like Josh Smith, I'm using a workspace viewmodel for the close command and ParentView and ChildView inherits from WorkspaceViewModel (which itsself inherits from ViewModelBase of course). Now, the problem is whenever I'm closing a child. The RequestClose event ist called by the ParentView and not by the ChildView. But the event is registered to the child. How is it possible that the RequestClose in WorkspaceViewModel is called by the child and not by the parent?
I have to add to my problem description that in this case I break the MVVM pattern and add my ChildView in the code-behind of the ParentView:
parentViewGrid.Children.Add(childView)
In this case sadly it's hardly possible to follow the MVVM pattern. For reasons look here: Polyline and MVVM . I haven't really solved that problem. In other words it's doubtful if following the MVVM pattern in this case is an advantage or disadvantage with reference to performance and complexity.
Hopefully you can help me and understand my problem. Thanks in advance.
Kai