Hey all.
So I'm in the middle of evaluating the RadTreeView control, and so far, it leaps ahead of other controls I've evaluated. I'm exploring the Drag/Drop functionality at the moment, but am really struggling, as I've not been able to find a consistent approach to tackle the problem in the online documentation.
I've basically got a RadTreeView and a RadListBox, each of their viewmodels have an ObservableCollection of HierachicalData. I can drag within the control, and between like controls (RadListBox to RadListBox), but can't get it working between the two.
I've attached my solution - when dragging from the TreeView, you can see the drop indicator on the ListBox, but drop is disabled.
My tree view looks like this :
.. with the following VM ...
And my RadListBox looks like this
With the following VM :
These exist in seperate user controls, with their own viewmodels. There is no code behind as I'm attempting to leverage as much of the existing framework as possiblle. I'm using the following version of the Telerik dlls 2014.2.729.45
So I'm in the middle of evaluating the RadTreeView control, and so far, it leaps ahead of other controls I've evaluated. I'm exploring the Drag/Drop functionality at the moment, but am really struggling, as I've not been able to find a consistent approach to tackle the problem in the online documentation.
I've basically got a RadTreeView and a RadListBox, each of their viewmodels have an ObservableCollection of HierachicalData. I can drag within the control, and between like controls (RadListBox to RadListBox), but can't get it working between the two.
I've attached my solution - when dragging from the TreeView, you can see the drop indicator on the ListBox, but drop is disabled.
My tree view looks like this :
<telerik:RadTreeView x:Name="TreeView" Grid.Row="1" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource ParentTemplate}" SelectionMode="Multiple" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsDragDropEnabled="True" AllowDrop="False" > <telerik:RadTreeView.ItemContainerStyle> <Style TargetType="telerik:RadTreeViewItem"> <Setter Property="IsSelected" Value="{Binding Path=Select, Mode=TwoWay}" /> <Setter Property="IsExpanded" Value="{Binding Path=Expand, Mode=TwoWay}"></Setter> </Style > </telerik:RadTreeView.ItemContainerStyle></telerik:RadTreeView>public class TelerikTreeViewModel : ReactiveScreen { private ObservableCollection<HierachicalData> _items; private HierachicalData _selectedItem; public TelerikTreeViewModel() { DisplayName = "Telerik Tree"; Items = new ObservableCollection<HierachicalData> { new HierachicalData { Name = "Parent", Expand = true, Select = true, Children = new ObservableCollection<HierachicalData> { new HierachicalData {Name = "Child 1"}, new HierachicalData {Name = "Child 2", Select = true} } }, new HierachicalData { Name = "Parent 2",Expand = true, Children = new ObservableCollection<HierachicalData> { new HierachicalData {Name = "Child 12", Select= true}, new HierachicalData {Name = "Child 22"} } } }; } public ObservableCollection<HierachicalData> Items { get { return _items; } set { this.RaiseAndSetIfChanged(ref _items, value); } } public HierachicalData SelectedItem { get { return _selectedItem; } set { this.RaiseAndSetIfChanged(ref _selectedItem, value); } } } public class HierachicalData : ReactiveObject { private string _name; private ObservableCollection<HierachicalData> _children; private bool _isSelected; private bool _expand; public HierachicalData() { } public string Name { get { return _name; } set { this.RaiseAndSetIfChanged(ref _name, value); } } public ObservableCollection<HierachicalData> Children { get { return _children; } set { this.RaiseAndSetIfChanged(ref _children, value); } } public bool Select { get { return _isSelected; } set { this.RaiseAndSetIfChanged(ref _isSelected, value); } } public bool Expand { get { return _expand; } set { this.RaiseAndSetIfChanged(ref _expand, value); } } }And my RadListBox looks like this
<Style x:Key="DraggableListBoxItem" TargetType="telerik:RadListBoxItem"> <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True"/> <Setter Property="telerik:DragDropManager.AllowDrag" Value="True" /> <Setter Property="telerik:DragDropManager.TouchDragTrigger" Value="TapAndHold"/> </Style><telerik:RadListBox x:Name="ListBox" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource ListBoxItemDataTemplate}" ItemContainerStyle="{StaticResource DraggableListBoxItem}" > <telerik:RadListBox.DragDropBehavior> <telerik:ListBoxDragDropBehavior/> </telerik:RadListBox.DragDropBehavior> <telerik:RadListBox.DragVisualProvider> <telerik:ScreenshotDragVisualProvider /> </telerik:RadListBox.DragVisualProvider> <telerik:RadListBox.DropVisualProvider> <telerik:LinearDropVisualProvider /> </telerik:RadListBox.DropVisualProvider> </telerik:RadListBox>With the following VM :
public class DataItemDropViewModel : ReactiveScreen { public DataItemDropViewModel() { Items = new ObservableCollection<HierachicalData> { new HierachicalData{Name = "Hello"}, new HierachicalData{Name = "Hello2"}, new HierachicalData{Name = "Hello3"}, }; } private ObservableCollection<HierachicalData> _items; public ObservableCollection<HierachicalData> Items { get { return _items; } set { this.RaiseAndSetIfChanged(ref _items, value); } } }These exist in seperate user controls, with their own viewmodels. There is no code behind as I'm attempting to leverage as much of the existing framework as possiblle. I'm using the following version of the Telerik dlls 2014.2.729.45