I'm working on a screen with WPF which has 3 listbox (list1, list2, list3), and i can drag items from list1 to list2 and list2 to list3 or even list1 to list3, and i can do it reversely.
I had to change the listbox (list3) to radListBox, because i wanted to implement the reorder within this list, i managed that drag and drop worked, and it did. but when a i wanted to drag an item from list3 (radlistbox), i got null in this variable :
" var data = ((DataObject)args.Data).GetData("DragData") as UcFileColumn", which UcFileColumn is a user control that i wanna cast with to drop in other lists. So insted od using "data" i thought using then selectedItem property to take the item dragged, and it works. Still one mysterious behaviour occured, is that when i dropped items in the lists3 (radListBox) and then drag them back into the lists(list1 or list2), and i wanted to dropped them back, the list prevent me to drop, i think when i remove item from teh radlistbox, the allowdrag dosent set anymore !!!!, is that because i used SelectedItem, if yes how should i get the element dragged from (DataObject)args.Data).GetData..
here is my XAML CODE :
I'm looking forward for your response
I had to change the listbox (list3) to radListBox, because i wanted to implement the reorder within this list, i managed that drag and drop worked, and it did. but when a i wanted to drag an item from list3 (radlistbox), i got null in this variable :
" var data = ((DataObject)args.Data).GetData("DragData") as UcFileColumn", which UcFileColumn is a user control that i wanna cast with to drop in other lists. So insted od using "data" i thought using then selectedItem property to take the item dragged, and it works. Still one mysterious behaviour occured, is that when i dropped items in the lists3 (radListBox) and then drag them back into the lists(list1 or list2), and i wanted to dropped them back, the list prevent me to drop, i think when i remove item from teh radlistbox, the allowdrag dosent set anymore !!!!, is that because i used SelectedItem, if yes how should i get the element dragged from (DataObject)args.Data).GetData..
here is my XAML CODE :
<
UserControl.Resources
>
<
Style
x:Key
=
"DraggableListBoxItem"
TargetType
=
"controls4:RadListBoxItem"
>
<
Setter
Property
=
"dragDrop:DragDropManager.AllowCapturedDrag"
Value
=
"True"
/>
<
Setter
Property
=
"dragDrop:DragDropManager.AllowDrag"
Value
=
"True"
/>
</
Style
>
</
UserControl.Resources
>
<
ListBox
Grid.Row
=
"2"
x:Name
=
"List1"
ItemsSource
=
"{Binding Source1, Mode=TwoWay}"
AllowDrop
=
"True"
IsSynchronizedWithCurrentItem
=
"True"
Style
=
"{StaticResource ListBoxStyleMenu}"
Margin
=
"2,2,2,2"
VerticalAlignment
=
"Stretch"
HorizontalContentAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
>
<
ListBox.ItemsPanel
>
<
ItemsPanelTemplate
>
<
UniformGrid
Columns
=
"2"
/>
</
ItemsPanelTemplate
>
</
ListBox.ItemsPanel
>
<
ListBox.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type ListBoxItem}"
>
<
Setter
Property
=
"Focusable"
Value
=
"False"
/>
<
Setter
Property
=
"Margin"
Value
=
"0,5,0,5"
/>
</
Style
>
</
ListBox.ItemContainerStyle
>
</
ListBox
>
<
ListBox
Grid.Row
=
"2"
x:Name
=
"List2"
ItemsSource
=
"{Binding Source2, Mode=TwoWay}"
AllowDrop
=
"True"
IsSynchronizedWithCurrentItem
=
"True"
Style
=
"{StaticResource ListBoxStyleMenu}"
Margin
=
"2,2,2,2"
VerticalAlignment
=
"Stretch"
HorizontalContentAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
>
<
ListBox.ItemsPanel
>
<
ItemsPanelTemplate
>
<
UniformGrid
Columns
=
"2"
/>
</
ItemsPanelTemplate
>
</
ListBox.ItemsPanel
>
<
ListBox.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type ListBoxItem}"
>
<
Setter
Property
=
"Focusable"
Value
=
"False"
/>
<
Setter
Property
=
"Margin"
Value
=
"0,5,0,5"
/>
</
Style
>
</
ListBox.ItemContainerStyle
>
</
ListBox
>
<
controls4:RadListBox
x:Name
=
"List3"
ItemsSource
=
"{Binding Source3}"
AllowDrop
=
"False"
SelectedItem
=
"{Binding SourceSelected, Mode=TwoWay}"
VerticalAlignment
=
"Stretch"
HorizontalContentAlignment
=
"Center"
HorizontalAlignment
=
"Stretch"
Margin
=
"2,2,2,2"
ItemContainerStyle
=
"{StaticResource DraggableListBoxItem}"
>
<
controls4:RadListBox.DragDropBehavior
>
<
behaviors:ListBoxDragDropBehavior
AllowReorder
=
"True"
dragDrop:DragDropManager.TouchDragTrigger
=
"TapAndHold"
/>
</
controls4:RadListBox.DragDropBehavior
>
</
controls4:RadListBox
>
I'm looking forward for your response