I'm use listview in the dragdropmanager. this is my xaml
<ListView Grid.Row="1" AllowDrop="True" ItemsSource="{Binding RecipeSeqList}" SelectionMode="Single">
<ig:DragDropManager.DropTarget> <ig:DropTarget IsDropTarget="True" ig:HighlightOnDragStart="True"/> </ig:DragDropManager.DropTarget>
<ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}"> <ig:DragDropManager.DragSource> <ig:DragSource IsDraggable="True" DragOver="DragSource_DragOver"/> </ig:DragDropManager.DragSource> </TextBlock> </DataTemplate> </ListBox.ItemTemplate> </ListView>
I want dragover change listitem array like this picture. ex) [1], [2], [3] drag -> [1], [3], [2]
but i can't.. help!
This solution was a good reference for me. My fault for not reading the manual!
Hello,
Thank you for posting to Infragistics Community!
I believe you will find the section of our documentation dedicated to the Infragistics Drag and Drop Framework quite helpful on the matter. There you will find topics explaining how to use it in detail as well as sample code-snippets and API links.
To address your specific question, while the ListView is a generic WPF component, not part of the Ultimate UI for WPF suite, the Infragistics Drag and Drop framework can work with it. The approach to achieve your requirement could follow the example given in this topic.
In your particular case, in addition to setting the TextBlock templated element as both a DragSource and a DropTarget, the DragSource’s Drop event should be handled in order to programmatically reorder the data items within the bound to the ListView collection, so that the reordering is performed. For example:
<ListView Name="listView" ItemsSource="{Binding Data}" Width="300" Height="200" Margin="0,50,0,0"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Country}" Width="270" Background="AliceBlue"> <ig:DragDropManager.DragSource> <ig:DragSource IsDraggable="True" Drop="DragSource_Drop"/> </ig:DragDropManager.DragSource> <ig:DragDropManager.DropTarget> <ig:DropTarget IsDropTarget="True" /> </ig:DragDropManager.DropTarget> </TextBlock> </DataTemplate> </ListBox.ItemTemplate> </ListView>
private void DragSource_Drop(object sender, Infragistics.DragDrop.DropEventArgs e) { ObservableCollection<DataModel> data = this.listView.ItemsSource as ObservableCollection<DataModel>; DataModel dragItemData = (e.DragSource as TextBlock).DataContext as DataModel; DataModel dropItemData = (e.DropTarget as TextBlock).DataContext as DataModel; int index = data.IndexOf(dragItemData); int targetIndex = data.IndexOf(dropItemData); data.RemoveAt(index); data.Insert(targetIndex, dragItemData); }
Attached you will find a sample demonstrating this suggestion. Please, feel free to further adapt it as per your specific requirements. If you require any further assistance on the matter, please, let me know.
Best regards, Bozhidara Pachilova Associate Software Developer
4382.ListViewDragDrop.zip