Skip to content
mycroes edited this page Feb 4, 2016 · 1 revision

The Tabablz IInterTabClient interface is used to tell Tabablz how to create new windows and what should be done when the last tab is removed from a window. The DefaultInterTabClient from Tabablz will take the owning Window of the TabablzControl, create a new instance of it's type (using Activator.CreateInstance) and searches for a TabablzControl inside that window to add the tab to.

IInterTabClient for Caliburn.Micro

The following is a simple implementation of IInterTabClient for use with Caliburn.Micro. It assumes a ShellViewModel ViewModel and ShellView View, which is a Window (so keep in mind that if your ShellView is a UserControl, this code won't do). Furthermore, the ShellView needs to expose the TabablzControl with the name Tabs.

using System.Windows;
using Caliburn.Micro;
using Dragablz;
using MyProject.ViewModels;
using MyProject.Views;

namespace MyProject.Infrastructure
{
    class InterTabClient : IInterTabClient
    {
        public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
        {
            var shell = new ShellView();
            shell.InitializeComponent(); // Only required if you don't have ShellView.xaml.cs
            var vm = IoC.Get<ShellViewModel>();

            ViewModelBinder.Bind(vm, shell, null);
            return new NewTabHost<Window>(shell, shell.Tabs);
        }

        public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
        {
            return TabEmptiedResponse.CloseWindowOrLayoutBranch;
        }
    }
}
Clone this wiki locally