Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabControlEx creates 2 instances of the first ContentTemplate. #144

Closed
darbid opened this issue Apr 6, 2021 · 0 comments
Closed

TabControlEx creates 2 instances of the first ContentTemplate. #144

darbid opened this issue Apr 6, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@darbid
Copy link

darbid commented Apr 6, 2021

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.

@darbid darbid added the Bug label Apr 6, 2021
@batzen batzen self-assigned this Apr 7, 2021
@batzen batzen added this to the 5.0.1 milestone Apr 7, 2021
@batzen batzen closed this as completed in 9a1c5d3 Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants