Adopting Caliburn to easy WPF MVVM development

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:

  1. Provide Out-of-box adapter for structureMap to hook up it’s standard IOC (Unity).
  2. Covention over configuration. VM in ViewModels, View in Views model, binding by same name.
  3. Context base binding, dependency property on view to control binding context specific view.
  4. Button on view will look for the matching name method on view model.
  5. 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:

  1. How to automatically hook up event handler between view and view model? such as,  hooking up closing event in shell view to shellviewmodel.Shutdown()
  2. Button can automatically bind to method, what about menu?
  3. Where is the context parameter in Open(Presenter, Action) method?
  4. The next version of caliburn will replacePresenter to screen, should we jump into it right now?

One thought on “Adopting Caliburn to easy WPF MVVM development

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s