This is a migrated thread and some comments may be shown as answers.

More compact DragCue

5 Answers 65 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 19 Aug 2011, 12:13 PM
Hi, I am currently implementing a multiple drag/drop from a GridView to a ListBox.  The actual drag and drop operation is working very nicely, but I am having a little issue with the TreeViewDragCue.  I am using the following code in the OnDragQuery:

//Set up a drag cue:
TreeViewDragCue tcue = new TreeViewDragCue();
tcue.ItemTemplate = this.Resources["UserDragTemplate"] as DataTemplate;
tcue.ItemsSource = e.Options.Payload as ObservableCollection<object>;
tcue.IsDropPossible = true;
e.Options.DragCue = tcue;

When I drag multiple items, they are displayed in the cue as a verticle stack of items, which is OK for 3 or 4, but when dragging 20 or more, the cue extends off the bottom of the screen which is not so nice to look at,   Is there a way of having the cue stack the items 'into' the screen (like a pack of playing cards slightly offset)?

Many thanks.

-- Edit --

So, I understand now why the cue is being shown as it is, the Template is set to:
<DataTemplate x:Key="UserDragTemplate">
    <StackPanel Orientation="Vertical">
        <Image Source="{Binding Image}" Height="30" Width="30" />
        <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" />
    </StackPanel>
</DataTemplate>

So, now my question would be what would be a better way of showing the multiple drag cue?
I can limit the number of items added to the ItemSource, but having the stacked vertically is not so nice.

Thanks again.

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 24 Aug 2011, 04:45 PM
Hi Stephen,

In this case the DataTemplate - "UserDragTemplate" targets each of the items in the TreeViewDragCue, not the whole drag cue. How exactly do you want your cue to look like ? Do you want a scroll bar, or to display the items horizontally ? 

Regards,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Stephen
Top achievements
Rank 1
answered on 30 Aug 2011, 09:44 AM
Hi, sorry for the delay in replying, bit of a crazy week.

What I am looking for is rather than a verticle or horizontal list of items, having a tiled stack to keep the multi-drag cue minimal.
0
Maya
Telerik team
answered on 02 Sep 2011, 11:52 AM
Hello Stephen,

You may define ItemsPanelTemplate for the TreeViewDragCue and set it as follows:

//XAML:
<ItemsPanelTemplate x:Key="ItemsPanelTemplate">
            <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
//C#:
    private void OnGridViewDragInfo(object sender, DragDropEventArgs e)
        {      
                var dragCue = new TreeViewDragCue() { ItemsSource = draggedItems };
                dragCue.ItemsPanel = this.Resources["ItemsPanelTemplate"] as ItemsPanelTemplate;
                dragCue.DisplayMemberPath = "Name";
                dragCue.DragTooltipVisibility = Visibility.Collapsed;
                e.Options.DragCue = dragCue;
                e.Options.Payload = draggedItems;
            }
             
        }

In this case the items to be dragged will be stacked horizontally. 
 

Kind regards,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Stephen
Top achievements
Rank 1
answered on 20 Sep 2011, 12:31 PM
Hi, sorry for the delay again, what we have at the moment is this:
http://i1221.photobucket.com/albums/dd480/TyreeC100/originaldrag.png

What I was looking for is something like:
http://i1221.photobucket.com/albums/dd480/TyreeC100/tileddrag.png

Thinking more about this, I doubt it is possible, so instead I started to look at limiting a multi-drag cue to just a single image and replace the text underneath with something like "+10 selected".   Unfortunately I could not work out how to programically change the text below the cue image after changeing the TextBlock from a bound value to a named attribute.
0
Syed Moshiur
Top achievements
Rank 1
answered on 01 Aug 2012, 03:00 PM
Is there still any way to condense the drag tree cue, to show something like one of many items dragging. 
If I am dragging 1000 items, i still want to use the tree drag cue, however i want to reduce the dragged items container to lets say "Item A + more" something similar?
Tags
DragAndDrop
Asked by
Stephen
Top achievements
Rank 1
Answers by
Maya
Telerik team
Stephen
Top achievements
Rank 1
Syed Moshiur
Top achievements
Rank 1
Share this question
or