views:

31

answers:

2

Hello EveryOne I am using WPF and I made some customecontrol just like a treeview, but this is the listtreeview so I am loading my all data into this treeview so it will take a much of time.

so I am worry about how to implement threading to improve the perfomance...

its urgent if u guys tell me.

Thanks..

+1  A: 

Thought about using Virtualization? See this question.

You can use VirtualizedStackPanel for a TreeView like this

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

And for a TreeViewItem style

<Style TargetType="{x:Type TreeViewItem}">
      <Setter Property="ItemsPanel">
        <Setter.Value>
          <ItemsPanelTemplate>
            <VirtualizingStackPanel />
          </ItemsPanelTemplate>
        </Setter.Value>
      </Setter>
</Style>
Meleak
A: 

Typically, long-running tasks in a GUI app use BackgroundWorker to avoid blocking the main thread. There is an example of using this in WPF here.

Steve Townsend