When I use the page down key or the mouse wheel to scroll down a virtualized RadTreeView, I get this bug:
The RadTreeViewItems that disappear are actually null when I get in to debug. Why does this happen? It's causing me a problem where a RadTreeViewItem I'm tracking suddenly disappears from memory, even though I have a few other pointers referencing it, it just goes away.
Let me know if there is a solution to this.
Thanks!
Here's my code:
XAML:
C#:
The RadTreeViewItems that disappear are actually null when I get in to debug. Why does this happen? It's causing me a problem where a RadTreeViewItem I'm tracking suddenly disappears from memory, even though I have a few other pointers referencing it, it just goes away.
Let me know if there is a solution to this.
Thanks!
Here's my code:
XAML:
<
Window
x:Class
=
"TreeViewComparison.Window1"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
Title
=
"Window1"
Height
=
"305"
Width
=
"627"
>
<
Window.Resources
>
<
HierarchicalDataTemplate
x:Key
=
"ItemTemplate"
ItemsSource
=
"{Binding SubItems}"
>
<
TextBlock
Text
=
"{Binding Header}"
/>
</
HierarchicalDataTemplate
>
<
Style
TargetType
=
"telerik:RadTreeViewItem"
>
<
Setter
Property
=
"IsExpanded"
Value
=
"True"
/>
</
Style
>
</
Window.Resources
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"*"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
telerik:RadTreeView
x:Name
=
"radTreeView"
Grid.Row
=
"0"
IsVirtualizing
=
"True"
ItemTemplate
=
"{StaticResource ItemTemplate}"
/>
<
Button
x:Name
=
"buttonBreakpoint"
Grid.Row
=
"1"
Margin
=
"8"
Content
=
"Breakpoint"
Click
=
"buttonBreakpoint_Click"
/>
</
Grid
>
</
Window
>
C#:
using
System;
using
System.Collections.ObjectModel;
using
System.Windows;
namespace
TreeViewComparison
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public
partial
class
Window1 : Window
{
public
Window1()
{
InitializeComponent();
this
.radTreeView.ItemsSource = GenerateItems();
}
private
ObservableCollection<DataItem> GenerateItems()
{
ObservableCollection<DataItem> result =
new
ObservableCollection<DataItem>();
for
(
int
i = 0; i < 10; i++)
{
DataItem item =
new
DataItem(String.Format(
"Item {0}"
, i));
for
(
int
j = 0; j < 100; j++)
{
item.SubItems.Add(
new
DataItem(String.Format(
"Item {0}.{1}"
, i,j)));
}
result.Add(item);
}
return
result;
}
class
DataItem
{
public
DataItem(
string
header)
{
this
.SubItems =
new
ObservableCollection<DataItem>();
this
.Header = header;
}
public
string
Header {
get
;
set
; }
public
ObservableCollection<DataItem> SubItems {
get
;
set
; }
}
private
void
buttonBreakpoint_Click(
object
sender, RoutedEventArgs e)
{
}
}
}