Skip to content

TabControlEx creates 2 instances of the first ContentTemplate. #144

@darbid

Description

@darbid

Describe the bug

It appears that using the TabControlEx creates 2 instances of the first ContentTemplate.

I have an example and hopefully not too complicated repo of this issue. Please forgive me if my coding is the problem, however, I believe I have created a fairly standard TabControl ViewModel project.
The project creates an ObservableCollection of ViewModels and uses a TemplateSelector to find the datatemplate as indicated below.

         <DataTemplate x:Key="TabBrowserDataTemplate"
                      DataType="{x:Type local:BrowserTabItemViewModel}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Button Grid.Row="0"
                        Content="Main Tab Button" />
                <local:BrowserTabItemUC  Grid.Row="1" />
            </Grid>
        </DataTemplate>

In MainWindow.xaml I have the following TabControlEx implementation and normal TabControl implementation. You can just change over to see the difference;

                <!--<cons:TabControlEx x:Name="BrowserTabControl"
                           SelectedIndex="{Binding BrowserTabControlSelectedIndex, Mode=TwoWay}"
                           ItemsSource="{Binding TabCollection}"
                           ContentTemplateSelector="{StaticResource selector}" />-->
        <TabControl x:Name="BrowserTabControl"
                    SelectedIndex="{Binding BrowserTabControlSelectedIndex, Mode=TwoWay}"
                    ItemsSource="{Binding TabCollection}"
                    ContentTemplateSelector="{StaticResource selector}" />

If you put a break on the creation of the UserControl BrowserTabItemUC and then use either the Standard TabControl or TabControlEX you will see that TabControlEX creates 2 instances of the usercontrol, even though only 1 ViewModel was created and added to the TabControls TabCollection.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions