Trying to make my first DragDrop among RadListBox working but not sure what I am missing - but I am sure that I am missing something. I just have two list boxes - one bound to available friends (from where the drag is initiated) and the other one bound to selected friends where the friends are dropped. But at this point, it just shows up as being dragged from the originating Radlistbox - but nothing comes in the other radlistbox. Pls help.
Here is my XAML and ViewModel. How does this work? Whenever I drop a friend - then ViewModel setter is also not called. So - how actually the OtherRadListBox gets bound to the dropped values.
Here is my XAML and ViewModel. How does this work? Whenever I drop a friend - then ViewModel setter is also not called. So - how actually the OtherRadListBox gets bound to the dropped values.
<
Window.DataContext
>
<
local:MainViewModel
/>
</
Window.DataContext
>
<
Window.Resources
>
<
Style
x:Key
=
"DraggableListBoxItem"
TargetType
=
"telerik:RadListBoxItem"
>
<
Setter
Property
=
"telerik:DragDropManager.AllowCapturedDrag"
Value
=
"True"
/>
</
Style
>
</
Window.Resources
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
/>
<
ColumnDefinition
/>
</
Grid.ColumnDefinitions
>
<
telerik:RadListBox
ItemContainerStyle
=
"{StaticResource DraggableListBoxItem}"
AllowDrop
=
"True"
Grid.Column
=
"0"
ItemsSource
=
"{Binding AvailableDropZones}"
DisplayMemberPath
=
"Name"
>
<
telerik:RadListBox.DragDropBehavior
>
<
telerik:ListBoxDragDropBehavior
/>
</
telerik:RadListBox.DragDropBehavior
>
</
telerik:RadListBox
>
<
telerik:RadListBox
ItemsSource
=
"{Binding SelectedDropZones}"
Grid.Column
=
"1"
AllowDrop
=
"True"
DisplayMemberPath
=
"Id"
>
<
telerik:RadListBox.DragDropBehavior
>
<
telerik:ListBoxDragDropBehavior
/>
</
telerik:RadListBox.DragDropBehavior
>
</
telerik:RadListBox
>
</
Grid>
public class MainViewModel :ViewModelBase
{
public MainViewModel()
{
ObservableCollection<Friend> list = new ObservableCollection<Friend>();
list.Add(new Friend() { Id = 1, Name = "Andy" });
list.Add(new Friend() { Id = 2, Name = "Josh" });
list.Add(new Friend() { Id = 3, Name = "Smith" });
list.Add(new Friend() { Id = 4, Name = "Andrew" });
AvailableDropZones = list;
}
ObservableCollection<Friend> availeble;
public ObservableCollection<Friend> AvailableDropZones
{
get
{
return availeble;
}
set
{
if (availeble != value)
{
availeble = value;
OnPropertyChanged("AvailableDropZones");
}
}
}
ObservableCollection<Friend> selected;
public ObservableCollection<Friend> SelectedDropZones
{
get
{
return selected;
}
set
{
if (selected != value)
{
selected = value;
OnPropertyChanged("SelectedDropZones");
}
}
}
}
public class Friend
{
public int Id { get; set; }
public string Name { get; set; }
}