AvalonDock 2 with Caliburn Micro

2020-06-17 05:41发布

问题:

Are there any blogs or articles about using AvalonDock with Caliburn Micro MVVM? Didn't find much when Googling

http://avalondock.codeplex.com/

edit: Got an up vote so why not update with a final solution. Full code can be found here

https://github.com/AndersMalmgren/FreePIE

Most of the avalon related code is found here

https://github.com/AndersMalmgren/FreePIE/blob/master/FreePIE.GUI/Shells/MainShellView.xaml

Update after Sam's answer

Its very, very little that needs to be done to enable Caliburn. First implement a LayoutItemTemplateSelector

public class AutobinderTemplateSelector : DataTemplateSelector
{
    public DataTemplate Template { get; set; }

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        return Template;
    }
}

And use it together with the content control and Caliburns View.Model attach mechanism like

<xcad:DockingManager.LayoutItemTemplateSelector>
    <avalonDock1:AutobinderTemplateSelector>
        <avalonDock1:AutobinderTemplateSelector.Template>
            <DataTemplate>
                <ContentControl cal:View.Model="{Binding . }" IsTabStop="False" />
            </DataTemplate>
        </avalonDock1:AutobinderTemplateSelector.Template>
    </avalonDock1:AutobinderTemplateSelector>
</xcad:DockingManager.LayoutItemTemplateSelector>

回答1:

http://caliburnmicro.codeplex.com/discussions/231809 and http://caliburnmicro.codeplex.com/discussions/430994 (solution)

I believe that is the post I used to create a similar doc manager for telerik's RadDockingManager. That post and this code might help.



回答2:

While researching this same thing I came across the Gemini framework being developed by Tim Jones:

Github - https://github.com/tgjones/gemini

Website - http://documentup.com/tgjones/gemini

It's an attempt to integrate AvalonDock with Caliburn.Micro to provide a single framework for building IDE-like applications. It's still in the early stages, but he's implementing some interesting abstractions that build upon Caliburn's overall design.

It also has some good demo applications that show how the framework could be used.