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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:58:53+00:00 2026-05-24T10:58:53+00:00

I have a data-bound TreeView with a WindowsFormsHost in the data template of its

  • 0

I have a data-bound TreeView with a WindowsFormsHost in the data template of its items. The more items in the TreeView, and so the more WindowsFormsHost in it, the slower the UI becomes.

The TreeView is in a TabItem, itself in a TabControl. The sluggishness is most obvious whenever the TabItem is selected (ie when I switch from another TabItem to the TabItem with the TreeView).

To simplify, I made a simpler app with a ListBox instead of a TreeView:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <TabControl>
        <TabItem Header="Tab 1">
            <StackPanel>
                <Button Content="Add 50 WindowsFormsHost controls" 
                        Click="Button_Click" />
                <ListBox Name="lst" Height="300">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=Bar}" />
                                <WindowsFormsHost />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
        </TabItem>
        <TabItem Header="Tab 2" />
    </TabControl>
</Window>

With this in the form’s code:

class Foo { public string Bar { get { return DateTime.Now.Ticks.ToString(); } } }

void Button_Click(object sender, RoutedEventArgs e)
{
    if (lst.ItemsSource == null)
        lst.ItemsSource = new ObservableCollection<Foo>();
     for (int j = 0; j < 50; j++)
        (lst.ItemsSource as IList<Foo>).Add(new Foo());
}

After clicking the button, scrolling the ListBox’s content becomes less fluid, and there is a delay when switching back to Tab 1.

Any ideas on why this is happening, and on if there is anything to do about it?

  • 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-24T10:58:54+00:00Added an answer on May 24, 2026 at 10:58 am

    Instead of hosting multiple WindowsFormsHost in a WPF ListBox’s items, why cant you host one WinForm ListBox having above items in a single WindowsFormsHost? This would not only make the scrolling easy (due to entirely in WinForms UI context) but also make your WPF app memory efficient (due to single WindowsFormsHost).

    If this is not what you are for, then try to loose the Virtualisation of your ListBox’s Items Panel (which by default is a VirtualizedStackPanel).

    Let me know if this helps?

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

Sidebar

Related Questions

I have bound a TreeView to an XMLDataProvider. The TreeView displays the data as
Say I have a 3-level data-bound WPF TreeView like this one: a aa aaa
I have a TreeView implemented in WPF that is bound to some XML data
I have a TreeView which uses a HierarchicalDataTemplate to bind its data. It looks
i have a asp.net tree view control and its being data bound to XML
I have a problem with a data-bound DataGrid control, in that despite each column
I have an ItemsControl that is data bound to a list of decimal s.
I have a .NET repeater control that is data-bound to a List. As part
I have a list control in Flex that has been data bound to an
i have little dilemma, i often use data-bound controls such as Gridview in conjunction

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.