More compact DragCue

6 posts, 0 answers
  1. Stephen
    Stephen avatar
    8 posts
    Member since:
    Jul 2011

    Posted 19 Aug 2011 Link to this post

    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.
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 24 Aug 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Stephen
    Stephen avatar
    8 posts
    Member since:
    Jul 2011

    Posted 30 Aug 2011 Link to this post

    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.
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  6. Stephen
    Stephen avatar
    8 posts
    Member since:
    Jul 2011

    Posted 20 Sep 2011 Link to this post

    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.
  7. Syed Moshiur
    Syed Moshiur avatar
    5 posts
    Member since:
    Oct 2011

    Posted 01 Aug 2012 Link to this post

    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?
Back to Top
DevCraft banner