I've made a simple example to reproduce a problem I'm having with the TreeView
. If I select an item in the TreeView
, scroll down, change the Focus
, and then select an item in the TreeView
again, the list starts jumping around.
This only happens if I have VirtualizingStackPanel.IsVirtualizing="True"
. Is this a known problem? Is there a work around?
So to reproduce:
I'm using .Net 3.5 SP1 and I've tried it for 64bit XP and Vista. I haven't tried it on other environments.
Update: I've tested in .Net 4.0 Beta and the issue doesn't occur. Is there a hotfix somewhere?
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Grid.Row="0"></TextBox>
<TreeView Grid.Row="1"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Standard"
>
<TreeView.Items>
<TreeViewItem Header="Header 1" IsExpanded="True">
<TreeViewItem.Items>
<TreeViewItem Header="Item 1" />
<TreeViewItem Header="Item 2" />
<TreeViewItem Header="Item 3" />
<TreeViewItem Header="Item 4" />
<TreeViewItem Header="Item 5" />
<TreeViewItem Header="Item 6" />
<TreeViewItem Header="Item 7" />
<TreeViewItem Header="Item 8" />
<TreeViewItem Header="Item 9" />
<TreeViewItem Header="Item 10" />
<TreeViewItem Header="Item 11" />
<TreeViewItem Header="Item 12" />
<TreeViewItem Header="Item 13" />
<TreeViewItem Header="Item 14" />
<TreeViewItem Header="Item 15" />
<TreeViewItem Header="Item 16" />
<TreeViewItem Header="Item 17" />
<TreeViewItem Header="Item 18" />
<TreeViewItem Header="Item 19" />
<TreeViewItem Header="Item 20" />
<TreeViewItem Header="Item 21" />
<TreeViewItem Header="Item 22" />
<TreeViewItem Header="Item 23" />
<TreeViewItem Header="Item 24" />
<TreeViewItem Header="Item 25" />
<TreeViewItem Header="Item 26" />
<TreeViewItem Header="Item 27" />
<TreeViewItem Header="Item 28" />
<TreeViewItem Header="Item 29" />
<TreeViewItem Header="Item 30" />
</TreeViewItem.Items>
</TreeViewItem>
</TreeView.Items>
</TreeView>
</Grid>
</Window>
Any help would be much appreciated!!!
Well, it looks like a bug and there is a plenty of hotfixes. Do you have Windows Update enabled?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With