I'm having issues getting the treeview's functionalities to work when in LoadOnDemand , notably drag and drop and AutoExpand,
1) AutoExpand on drag doesn't work , if i remove the load on demand it works , however load on demand itself seems to work just fine
2) Droping doesn't seem to load the node either , when i drop on an unloaded node it opens with only the node i have droped instead of it's actual content.
Is this scenario supported, if so what am i doing wrong , else any tips on how to implement it? I am using the latest Q2 version and WPF 4 / VS 2010.
Thanks!
Full code (couldn't find how to properly paste code on forums , any tips most welcome):
XAML :
<
Window x:Class="RadControlsWpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Tree="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
Title="MainWindow" Height="350" Width="525">
<Grid>
<!--If you uncomment the line , autoexpand works just fine-->
<Tree:RadTreeView ItemsSource="{Binding Items}"
IsLoadOnDemandEnabled="True"
LoadOnDemand="RadTreeView_LoadOnDemand"
IsDragDropEnabled="True">
<Tree:RadTreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}"></TextBlock>
</HierarchicalDataTemplate>
</Tree:RadTreeView.ItemTemplate>
</Tree:RadTreeView>
</Grid>
</
Window>
Code behind:
using
System;
using
System.Collections.Generic;
using
System.Windows;
using
System.Windows.Navigation;
using
Telerik.Windows.Controls;
using
System.ComponentModel;
namespace
RadControlsWpfApp1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
Items =
new List<object>(){
new Item{Id = 1 , Name = "1"},
new Item{Id = 2 , Name = "2"},
new Item{Id = 3 , Name = "3"},
new Item{Id = 4 , Name = "4"},
new Item{Id = 5 , Name = "5"}
};
}
public List<object> Items { get; set; }
private void RadTreeView_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
var Current = item.Item as Item;
Current.Children =
new List<object>(){
new Item{Id = 1 , Name = "1"},
new Item{Id = 2 , Name = "2"},
new Item{Id = 3 , Name = "3"},
new Item{Id = 4 , Name = "4"},
new Item{Id = 5 , Name = "5"}
};
item.IsLoadingOnDemand =
false;
}
}
public class Item : INotifyPropertyChanged
{
public int Id { get; set; }
public string Name { get; set; }
List<object> children = new List<object>();
public List<object> Children
{
get
{
return children;
}
set
{
children =
value;
PropertyChange(
"Children");
}
}
public event PropertyChangedEventHandler PropertyChanged = (a, b) => { };
public void PropertyChange(string propertyName)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}