Quantcast
Viewing all articles
Browse latest Browse all 18858

WPF: When the content of two TabItems are identical, the content of one disappears when switching between tabs.

Hello!

I have a Window with two tabs, as follows:

<TabControl Padding="0" >

<TabItem Header="Products" x:Name="TabItem1" >
<Grid>
                     <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <ContentControl Content="{Binding ProdListView}" Grid.Row="0" Grid.Column="1" Margin="0,0,5,0" />
</Grid>
</TabItem>

<TabItem Header="Products" x:Name="TabItem2" >
<Grid>
                     <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <ContentControl Content="{Binding ProdListView}" Grid.Row="0" Grid.Column="1" Margin="0,0,5,0" />
</Grid>
</TabItem>

</TabControl>

ProdListView is XAML with DataGrid.

When I click on TabItem1, it displays all the data, and when I click on TabItem2, it also displays all the data. However, when I click back on TabItem1, the tab content is blank and when I click on TabItem2, the data is displayed again.  When I use a different view control instead of ProdListView on one of the TabItems, everything works fine.

I need this kind of set-up as I use ProdListView for two different master/detail views.

Many thanks for your help.

Abbas




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>