Hello Coders,
For example I have 2 different ViewModel class like VM1, VM2 and I have two different UserControl based View class like V1 and V2. V1's job is to display data of VM1 and V2 will display datas of VM1. I'd like to put the V1 and V2 into different Dragablz Tab.
in *.CS:
Tabs.Add(new Dragablz.HeaderedItemViewModel()
{
Header = "Tab1",
Content = new ViewModel1()
});
Tabs.Add(new Dragablz.HeaderedItemViewModel()
{
Header = "Tab2",
Content = new ViewModel2()
});
in *.xaml:
<dockablz:Layout>
<dragablz:TabablzControl
x:Name="tabControl"
ItemsSource="{Binding Tabs}"
Margin="8"
UseLayoutRounding="True"
ShowDefaultAddButton="False"
ShowDefaultCloseButton="True"
ClosingItemCallback="{Binding ClosingTabItemHandler}"
HeaderMemberPath="Header"
DisplayMemberPath="Content"
>
<dragablz:TabablzControl.InterTabController>
<dragablz:InterTabController ></dragablz:InterTabController>
</dragablz:TabablzControl.InterTabController>
</dragablz:TabablzControl>
</dockablz:Layout>
How could I bind together the corresponding ViewModels and Views on the tabs? (On "Tab1" should display a View1 which is binded to Tab1's Content (a ViewModel1 object)
I think TabablzControl's ContentTemplate not going to work because I have different View types and different ViewModel types.
Every example on the Internet (what I did found) was "Hello world" level, or hard coded in XAML with "TabItem" tags
IViewModel
that would be implemented by both?
Content is Object so it does not count that VM1 or VM2 has a common IViewModel interface or not
(note:this is Dragablz code):
#region Assembly Dragablz, Version=0.0.3.203, Culture=neutral, PublicKeyToken=null
#endregion
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Dragablz
{
//
// Summary:
// Helper class to create view models, particularly for tool/MDI windows.
public class HeaderedItemViewModel : INotifyPropertyChanged
{
public HeaderedItemViewModel();
public HeaderedItemViewModel(object header, object content, bool isSelected = false);
public object Header { get; set; }
public object Content { get; set; }
public bool IsSelected { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null);
}
}
So the question is, how could I tell to TabablzControl that use View1 class if the Content is ViewModel1?