Caliburn.Micro & Infragistics XamDockManager + TabGroupPane
I'm trying to get the Infragistics TabGroupPane to inte开发者_开发问答grate with Caliburn.Micro as per the standard WPF TabControl.
I've tried adding a new convention in the bootstrapper (a modification of the standard WPF one) but have not had any success.
My TabGroupPane is defined as:
<igDock:TabGroupPane x:Name="Items"/>
When an item is added to the collection an exception is thrown "InvalidOperationException: A TabGroupPane can only contain 'ContentPane' and 'ContentPanePlaceholder' instances".
Also, if my TabGroupPane is inside a DockManager:
<igDock:XamDockManager>
<igDock:DocumentContentHost>
<igDock:SplitPane>
<igDock:TabGroupPane x:Name="Items" />
</igDock:SplitPane>
</igDock:DocumentContentHost>
</igDock:XamDockManager>
It doesn't appear to be found by Caliburn at all.
Has anyone else done this before?
Cheers!
Update
I have created my own dock manager class, a blog post explaining it or just the code on bitbucket. Hopefully this will be useful to someone!If you can't get the ContentPaneFactory suggested in Infragistics blog to fill the TabGroupPane through binding, you might consider these alternative approaches:
- keep your VM with BindableCollection in place, subscribe VM change notification in code-behind and change the TabGroupPane programmatically according to the actual change occurred in observed collection
- build a custom IResult and invoke it from VM (using Coroutine.Execute) according to the desired TabGroupPane variation.
In IResult.Execute body you have access to ActionExecutionContext.View, so you can reach the TabGroupPane by name and operate whathever action you need on it.
This way you keep your VM free from direct reference to the particular UI control library. - define an interface abstracting the whole Docking Manager, and use it as a service from VM (see this post about the implementation of a Docking Manager). This approach diverges quite a lot from the MVVM idea, but unfortunately most docking library are not very MVVM friendly...
You can add bespoke controls to the ConventionManager class in Caliburn Micro, I would simply follow the example of the standard TabGroupPanel.
I would be wary of amending the actual class though, If I remember rightly (there is a recent post on the discussion forums at CaliburnMicro Codeplex page) You can also add bespoke conventions to the bootstrapper by overriding the Config method? I say this because if you amend the class itself, you will tie yourself to a particular version of Caliburn.
Its a really simple framework and easy to get to know intimately, I would recommend stepping through the code thats run when you bind a view to a viewmodel, there you will learn how these conventions are setup.
Have you tried using a more explicit binding? Caliburn can only do automatic binding on certain elementtypes, and I guess Infragistics TabGroupPane is not one of them!
I guess you have to use something like this:
<igDock:TabGroupPane x:Name="Items" ItemSource={Binding <what to bind to>}/>
Note: This is just used as an example, not sure if ItemSource is the correct property!
精彩评论