开发者

Opening new workspace from child viewmodel

开发者 https://www.devze.com 2023-03-03 19:28 出处:网络
i\'开发者_JAVA技巧ve written a project that is based on the MVVM customer example on MSDN. How would i add a new workspace from a child view model? I don\'t like the idea of making the Workspaces coll

i'开发者_JAVA技巧ve written a project that is based on the MVVM customer example on MSDN. How would i add a new workspace from a child view model? I don't like the idea of making the Workspaces collection static as this seems to go against the pattern.

i'm effectively trying to add a new customer view when an element in the allcustomers view is double clicked.

thanks in advance


One "simple" solution is to pass the ParentViewModel into the child ViewModel's constructor. Then you can simple call the Add logic on the ParentViewModel from wherever you want in the child's code.


I realize this is an older post, but, for the record, I added a static WorkspaceManager class that exposes methods for adding and activating Workspaces. The WorkspaceManager maintains the Workspaces collection. Any class can call the static methods, so the Main window or parent doesn't have to maintain the Workspaces collection or have any knowledge on how the Workspace functionality is actually implemented.

J

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号