Dragablz组件并使用不同的窗口作为主机

时间:2015-08-21 15:12:06

标签: .net wpf

我尝试使用IInterTabClient实现辅助窗口作为Dragablz可撕后选项卡控件的窗口主机: 公共类TRInterTabClient     实现Dragablz.IInterTabClient

Public Function GetNewHost(interTabClient As Dragablz.IInterTabClient, partition As Object, source As Dragablz.TabablzControl) As Dragablz.INewTabHost(Of Window) Implements Dragablz.IInterTabClient.GetNewHost
    Dim host As New TabHost
    Return New Dragablz.NewTabHost(Of TabHost)(host, host.tabContainer)
End Function

Public Function TabEmptiedHandler(tabControl As Dragablz.TabablzControl, window As Window) As Dragablz.TabEmptiedResponse Implements Dragablz.IInterTabClient.TabEmptiedHandler
End Function

结束课程 我没有使用MVVM模式,所以我认为创建一个DependencyProperty来暴露Tab Client会起作用,但我收到一个错误,说明"必须在InterTabController上提供InterTabClient。"

Public Shared ReadOnly InterTabClientProperty As DependencyProperty =
    DependencyProperty.Register("InterTabClientInstance",
                            GetType(TRInterTabClient),
                            GetType(MainWindow),
                            New PropertyMetadata(Nothing))

Public Property InterTabClientInstance As TRInterTabClient
    Get
        If GetValue(InterTabClientProperty) Is Nothing Then InterTabClientInstance = New TRInterTabClient
        Return DirectCast(GetValue(InterTabClientProperty), TRInterTabClient)
    End Get
    Set(value As TRInterTabClient)
        SetValue(InterTabClientProperty, value)
    End Set
End Property

很明显,我做错了什么或误解了如何完成我想要的事情,任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:2)

InterTabController上的InterTabClient属性是必需的,因此当您创建新窗口和新TabablzControl时,您需要手动重新设置它,因为您没有使用MVVM。请原谅C#语法,但在IInterTabController中你可以这样做:

    public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
    {
        var view = new BasicExampleTemplateWindow();            
        view.TabablzControl.InterTabController = new InterTabController()
        {
            InterTabClient = this
        };
        return new NewTabHost<Window>(view, view.TabablzControl);
    }

注意我如何将InterTabClient设置为当前实例。

如果您仍然遇到问题,请在GitHub上发布样本,我会帮助您解决问题。