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

DragCue Missing

2 Answers 65 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Stephen Rouse
Top achievements
Rank 1
Stephen Rouse asked on 16 Aug 2012, 05:06 PM
I have a treeview which has three "levels" Category; SubCategories and Products. Sourced from AdventureWorks DB during the feasibility stage of the project. This treeview works as expected; expands etc (see treeviewexpanded.png). I have been trying "Drag and Drop" to a GridView which is also working as I expected. However, I do not get a Drag Cue, I have included a screen shot of the cue that I get, which is just a blue square/dot ? 

The Treview Items source is an ObserveableCollection of QuoteItems declared as follows:
/// Quote Items, Holds the Hierarchical data setin the form of
///
/// Category
/// + SubCategory
/// -+Product
///
/// </summary>
public class QuoteItem
{
 
    public string name { get; set; }
    public ProductCategory Category { get; set; }
    public List<ProductItem> SubCategories { get; set; }
    public bool Selected { get; set; }
    public bool Expanded { get; set; }
 }

Product Item is declared as
public class ProductItem
{
    public string name { get; set; }
    public ProductSubcategory SubCategory { get; set; }
    public List<Product> Products { get; set; }
    public bool Selected { get; set; }
    public bool Expanded { get; set; }
}

The Datatemplate for the Tree is defined as follows :
<!--Data template for the Product object-->
<telerik:HierarchicalDataTemplate x:Key="ProductTemplate" >
    <TextBlock Text="{Binding Name}"  Foreground="DarkBlue" />
</telerik:HierarchicalDataTemplate>
 
<!--Data template for the Sub-Category object-->
<telerik:HierarchicalDataTemplate 
    x:Key="SubCategoryTemplate"
    ItemTemplate="{StaticResource ProductTemplate}"
    ItemsSource="{Binding  Products}">
    <TextBlock Text="{Binding SubCategory.Name}" />
</telerik:HierarchicalDataTemplate>
 
<!--Data template for the Category object-->
<telerik:HierarchicalDataTemplate 
    x:Key="CategoryTemplate"
    ItemTemplate="{StaticResource SubCategoryTemplate}"
    ItemsSource="{Binding SubCategories}">
    <!--<TextBlock Text="{Binding Name}" />-->
    <TextBlock Text="{Binding Category.Name}" />
</telerik:HierarchicalDataTemplate>

The Tree View & Grid are declared as

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<telerik:RadBusyIndicator IsBusy="{Binding Path=TreeLoading}" x:Name="TreeViewBusyIndicator" Grid.Column="0" >
    <telerik:RadTreeView Grid.Column="0" x:Name="ProductTree"  Margin="4,5" ItemTemplate="{StaticResource CategoryTemplate}"
                         IsLoadOnDemandEnabled="False"  IsExpandOnSingleClickEnabled="True" SelectionMode="Multiple" AllowDrop="False"
                         IsDragDropEnabled="True" IsDragTooltipEnabled="False"  >
    </telerik:RadTreeView>
          </telerik:RadBusyIndicator>
 
<telerik:RadGridView x:Name="RoomQuoteGridView" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" 
                     Grid.Column="1" HorizontalAlignment="Left" telerik:RadDragAndDropManager.AllowDrop="True">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Name}" IsFilterable="False" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ListPrice, StringFormat=\{0:c\}}" IsFilterable="False" />
        <!--<telerik:GridViewDataColumn DataMemberBinding="{Binding ImageUrl}"/>-->
    </telerik:RadGridView.Columns>
 
</telerik:RadGridView>

I have trawled the help files, forums etc and downloaded a number of examples, by the way a treeview to GridView sample in the help files does not work, just produces errors, I expect this is due to some changes in the structure, but anyway that is a side issue.

I just wish to have a drag cue as per the demo(s) but it does not appear!!!

I have spent the last few days on this, changing various properties, methods etc and only managed to get the cue working, when the top level (Category) bing was changed to Name instead of Category Name, however the items(Categories) did not appear in the tree. I obviously cannot see the wood for the trees etc, anyone have a similar issue and "fixed" it.

Steve








2 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 17 Aug 2012, 01:47 PM
Hi,

I guess you have a problem with setting the DragCue in your code. I can suggest you to do the following:
1) In your DragInfoHandler:
IEnumerable draggedItems = e.Options.Payload as IEnumerable;
 
if (e.Options.Status == DragStatus.DragInProgress)
{
    //Set up a drag cue: 
    TreeViewDragCue cue = new TreeViewDragCue();
    //Here we need to choose a template for the items: 
    cue.ItemTemplate = this.Resources["MyTemplate"] as DataTemplate;
    cue.ItemsSource = draggedItems;
    e.Options.DragCue = cue;
}

2) In your DropQueryHandle:
if (e.QueryResult)
{
    TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
    cue.IsDropPossible = true;
}

3) In your DropInfoHandler:
TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
cue.IsDropPossible = true;
if (e.Options.Status == DragStatus.DropPossible)
{
    // Set a suitable text: 
    string newString;
    newString = String.Format("Add {0}", draggedItems.Count);
    cue.DragActionContent = newString;
 
    cue.IsDropPossible = true;
}

This should work. If you face any problems feel free to contact us and if possible send us a sample project to reproduce the issue and the exact way of using DragCue.
I'd like to recommend you to use our newer DragDropManager instead of RadDragAndDropManager. It has some other features they may help you. For more information you can check our online help here.

Kind regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Stephen Rouse
Top achievements
Rank 1
answered on 30 Aug 2012, 02:04 PM
I tried the suggestion you gave, but with the same result. I then decided to use the DragDropManager as suggested.

I'd like to recommend you to use our newer DragDropManager instead of RadDragAndDropManager. It has some other features they may help you. For more information you can check our online help here

This at least enabled me to get a DragCue, although the documentation appears a little sparse and probably version 1. I decided to use one the demos and work on that, but after that I have reintroduced the lack of a cue, or indeed other side affects. I will do some more investigation, and if possible split out the project to provide you with a sample to investigate.
Tags
DragAndDrop
Asked by
Stephen Rouse
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Stephen Rouse
Top achievements
Rank 1
Share this question
or