How to manage child window/tabpages, like open/close, close-query event, …? I was wondering about this for a long time when starting MVVM pattern.
In another word, where is the best place to hold the states of all child tabs? The storytellor example created by Jeremy Miller was using shell presenter to control this. Same as the caiburm framework, RootViewModel is acting as a multi-presenter manager. Open a new presenter just add a new item into presenters property of shell view model, as long as the tabcontrol on view bind to this presenter property, the tabpage will be fully controlled by shell view model, as this post explained.
But, we are using AvalonDock tab control in our WPF app, the datacontext of Avalon dockingManger can only be DocumentContent, can’t be the invisible viewmodel/presenter. An typeConverter might fix this problem, but my xaml skill is too poor, I create a complete action for Open(Presenter) method provided by caliburn.
Some nice features I really like from Caliburn:
- Provide Out-of-box adapter for structureMap to hook up it’s standard IOC (Unity).
- Covention over configuration. VM in ViewModels, View in Views model, binding by same name.
- Context base binding, dependency property on view to control binding context specific view.
- Button on view will look for the matching name method on view model.
- Show static class to solve the classic question of popping up message box in view model.(I haven’t fully understand IResult yet, but it’s cool and very flexible).
Some questions to answer:
- How to automatically hook up event handler between view and view model? such as, hooking up closing event in shell view to shellviewmodel.Shutdown()
- Button can automatically bind to method, what about menu?
- Where is the context parameter in Open(Presenter, Action) method?
- The next version of caliburn will replacePresenter to screen, should we jump into it right now?