Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:58:42+00:00 2026-06-11T22:58:42+00:00

I have a WPF issue that I don’t understand – can anyone help? The

  • 0

I have a WPF issue that I don’t understand – can anyone help?

The WPF below is used as the ContentTemplate for a standard TabControl and resides within a ResourceDictionary. MyElementItemsControl is a simple derivative of ItemsControl and MyDesignCanvas is a simple derivative of Canvas.

    <DataTemplate x:Key="TabContent"  x:Shared="False">
    <Grid>
        <Grid Grid.RowSpan="2">
            <ScrollViewer x:Name="contentScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
                <Grid>
                    <View:MyElementItemsControl BorderBrush="Transparent" x:Name="schedulePanel" ItemsSource="{Binding Path=Elements}" Background="White">
                        <View:MyElementItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <View:MyDesignCanvas Height="1000" Width="1000" HorizontalAlignment="Left" VerticalAlignment="Top" 
                                                                     SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                                                                     Background="Transparent">
                                </View:MyDesignCanvas>
                            </ItemsPanelTemplate>
                        </View:MyElementItemsControl.ItemsPanel>
                    </View:MyElementItemsControl>

                    <Grid.LayoutTransform>
                        <TransformGroup>
                            <ScaleTransform>
                                <ScaleTransform.ScaleX>
                                    <Binding ElementName="SlideZoom" Path="Value" Mode="OneWay"/>
                                </ScaleTransform.ScaleX>
                                <ScaleTransform.ScaleY>
                                    <Binding ElementName="SlideZoom" Path="Value" Mode="OneWay"/>
                                </ScaleTransform.ScaleY>
                            </ScaleTransform>
                        </TransformGroup>
                    </Grid.LayoutTransform>

                </Grid>
            </ScrollViewer>

        </Grid>

        <Slider Opacity="0.5" VerticalAlignment="Top" HorizontalAlignment="Left" Width="300" Grid.Row="1" Name="SlideZoom" Orientation="Horizontal" Minimum="0.1" Maximum="3" Value="1">
        </Slider>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>

    </Grid>
</DataTemplate>

When I run the code I get two issues I don’t understand:

  1. I seem to only get a single ScrollViewer when I would expect a ScrollViewer per item. So if I add two tab items and make the canvas different sizes, the scroll bars are adjusted to the size of the biggest canvas only. I expected that the Shared=False attribute would create new instances of the template for each tab.
  2. Maybe related to item 1 – if I stick a breakpoint on the constructor of MyDesignCanvas it gets hit when the first tab is added but not when other tabs are added. Only when I start closing tabs does the breakpoint get hit again – I would expect a hit on each tab addition.

I guess I don’t really understand data templating enough, so can anyone explain what might be going on or point me at some resources that may help me diagnose this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:58:43+00:00Added an answer on June 11, 2026 at 10:58 pm

    I’ve realised what the issue is – the WPF TabControl does internal virtualization of tab content, so has been re-using the tab contents and just changing the data context despite me using Shared=False. See this SO question and this one too for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that uses WPF Composite, and I have an issue. I've
I have WPF Span that is used as a source to a TextBlock. I
So I have several comboboxes in my WPF application that don't change the selection
I have a WPF sorting/binding issue. (Disclaimer: I am very new to WPF and
I have a very basic databinding issue with the Visifire WPF charting tool in
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
I need to have a command handler for a ToggleButton that can take multiple
I have a few user controls I made in wpf that are driven by
The Situation I have a WPF program that I want to print several documents
I have a winforms application that I'd like to add a WPF user control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.