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 7597649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:12:29+00:00 2026-05-30T22:12:29+00:00

Background I have a custom control that inherits from a TreeView and is modified

  • 0

Background

I have a custom control that inherits from a TreeView and is modified to display in a data grid style. The problem I am seeing is with performance when expanding the tree. This is common from my research with Tree Views. Upon inspection with the WPF Performance tools I noticed that the ItemsPresenter class is using a regular Stack Panel instead of a Virtualizing Stack Panel.

enter image description here

Here is the section of code where the ScrollContentPresenter is used (showing in image).

<ScrollContentPresenter Name="PART_ScrollContentPresenter"
      KeyboardNavigation.DirectionalNavigation="Local"
      Content="{TemplateBinding Content}"
      ContentTemplate="{TemplateBinding ContentTemplate}"
      CanContentScroll="{TemplateBinding CanContentScroll}"
      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

Here is the template being passed in.

    <ControlTemplate TargetType="CommonControls:TreeListViewItem508">
    <Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Border x:Name="item">
            <Border Name="InnerBorder">
                <Grid Style="{StaticResource GridBackgroundStyle}">
                    <Rectangle Visibility="Collapsed" Fill="#75FFFFFF" Name="UpperHighlight" />
                </Grid>
            </Border>
        </Border>
        <ItemsPresenter Grid.Row="1" Name="ItemsHost" />
    </Grid>
</ControlTemplate>

Question

Is it possible to force the items presenter to use a virtualizing stack panel?

Notes

  • I have already tried wrapping the ItemsPresenter in a ScrollViewer but that gives undesired results (scroll bars for each row).
  • I hard coded the option CanContentScroll = true as a test since this disables virtualization when its set to false.
  • This control is in production and used in multiple places so I don’t have the option to replace / rewrite / or perform major modifications to the design at this point. I am just looking to override this one section if possible.

Any suggestions or options are much appreciated.

Resolved:

I modified the template’s style by adding this to the style and it switched the stack panels to virtualizing.

 <Setter Property="ItemsPanel">
        <Setter.Value>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel />
            </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>
  • 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-05-30T22:12:31+00:00Added an answer on May 30, 2026 at 10:12 pm

    Try

          <TreeView>
            <TreeView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel/>
                </ItemsPanelTemplate>
            </TreeView.ItemsPanel>
        </TreeView>
    

    or

    <TreeView VirtualizingStackPanel.IsVirtualizing="True">
    

    Obviosuly replace TreeView, with your treeview control name.

    Hope that helps

    Paul

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

Sidebar

Related Questions

The background is I have a custom control that is a asp:Menu that is
Background: I have a custom user control based around a WPF TreeView. I've been
Background I have a custom collection that is binded to the datagridview this.datagridview.DataSource =
I have a dialog that resizes. It also has a custom background which I
Background: we have an application that generates reports from HTML (that may or may
I'm using Microsoft Windows Phone 7 Tools Beta. I have a custom control that
So I have made a custom required field validator that turns the background of
I have a very specific problem. I have a user control (code below) That
I have a custom control that I'm using as a rubber band which paints
I have a custom control containing a path that has a templated tooltip. I

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.