I make a treelistview with an itemssource that contains two List items.
When I push a button, I move the last item in as a child on the first item.
But to get this to work, I need to:
radTreeListView.ItemsSource = null; radTreeListView.ItemsSource = source;This operation takes 600 ms when working with 1.000 rows so it is not desirable.
I have tried to make the List item in to an ObservableCollection but with no luck.
Are there any suggestion to an alternative handling?
The XAML:
<Grid> <telerik:RadTreeListView x:Name="radTreeListView" AutoGenerateColumns="False"> <telerik:RadTreeListView.ChildTableDefinitions> <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" /> </telerik:RadTreeListView.ChildTableDefinitions> <telerik:RadTreeListView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" /> </telerik:RadTreeListView.Columns> </telerik:RadTreeListView> </Grid>The code behind:
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); List<Item> itemList = new List<Item>(); itemList.Add(new Item("Drink")); this.radTreeListView.ItemsSource = itemList; radTreeListView.Loaded += delegate(object sender, RoutedEventArgs e) { List<Item> source = ((List<Item>)radTreeListView.ItemsSource); source.First().Children.Add(new Item("Carrot")); //This works but takes time when I have 1.000 posts: radTreeListView.ItemsSource = null; radTreeListView.ItemsSource = source; //Refresh radTreeListView radTreeListView.Rebind(); }; } } public class Item { public Item(string name) { this.Name = name; this.Children = new List<Item>(); } public string Name { get; set; } public List<Item> Children { get; set; } }