0

I have a requirement to load the avalondock [1] control inside each tab of a tabcontrol.

[1] - http://avalondock.codeplex.com/wikipage?title=AvalonDock%202.0%20Getting%20Start%20Guide

Before complicating this, I have written a simple poc app to just load tabItems from my viewmodel & load the dock control in each tab, xaml below...

<TabControl ItemsSource="{Binding TabItems}">
    <TabControl.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Header}" />
        </DataTemplate>
    </TabControl.ItemTemplate>
    <TabControl.ContentTemplate>
        <DataTemplate>
            <!--<TextBlock Text="{Binding Content}" />-->
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Text="{Binding Content}"></TextBlock>
                <xcad:DockingManager Grid.Row="1" x:Name="dockingManager" VerticalAlignment="Top" Background="Red"  Width="500" Height="500" >
                    <xcad:LayoutRoot>
                        <xcad:LayoutPanel Orientation="Horizontal">
                            <xcad:LayoutDocumentPane>
                                <xcad:LayoutDocument Title="Document 1">
                                    <TextBlock x:Name="dockTextBlock" Background="Green" VerticalAlignment="Top" Text="Hello World"></TextBlock>
                                </xcad:LayoutDocument>
                            </xcad:LayoutDocumentPane>
                        </xcad:LayoutPanel>
                    </xcad:LayoutRoot>
                </xcad:DockingManager>
            </Grid>
        </DataTemplate>
    </TabControl.ContentTemplate>
</TabControl>

My View Model is passing the following...

TabItems = new ObservableCollection<TabItem>()
{
    new TabItem(){Header  = "Tab 1", Content = "I am tab 1"},
    new TabItem(){Header = "Tab 2", Content = "I am tab 2"}
};

private ObservableCollection<TabItem> _tabItems;

public ObservableCollection<TabItem> TabItems
{
    get { return _tabItems; }
    set
    {
        _tabItems = value;
        RaisePropertyChanged(() => TabItems);
    }

}

The tab items are loading correctly and I can see the Content, but the dockcontrol does not load, I was expecting to see the dockcontrol with a Hello World text box in each tab. Clearly I am missing something.

Has someone run into this? Is it a data context problem? Any thoughts?

Soma
  • 861
  • 2
  • 17
  • 32
Tarun Arora
  • 4,692
  • 4
  • 30
  • 40

1 Answers1

0

I have found a solution for this, it wasn't as difficult as i though. Though credit goes to the Avalondock control for designing the control to allow for this solution.

I got my idea & implementation from this codeproject sample http://www.codeproject.com/Articles/483533/AvalonDock-2-0-Tutorial-Part-2-Adding-a-Start-Page

Tarun Arora
  • 4,692
  • 4
  • 30
  • 40