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

Drag & Drop from ItemsControl to RadTileView

2 Answers 93 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Paulius Putna
Top achievements
Rank 1
Paulius Putna asked on 15 Mar 2012, 06:33 AM
Hello,

I have a problem setting up drag & drop using telerik provided manager. Let me explain what I want to do:

I have an ItemsControl where I have templates of items and then I drag one of the templates to a RadTileView and it creates an instance of an item with that template. The idea in my application is that I have a list of available metrics (charts, maps) in ItemsControl and user should be able to drag any of those to RadTileView to create an instance of that type of metric and show some data. He should be able to create as many instances of same kind of chart or map as he wants so it has to be as generic as possible.

I also want to make this as MVVM as possible, since I have to persist the RadTileView layout and each of the charts individual settings.

I could not find any usable examples on how to implement this using new DragAndDrop framework, some a simple example of what I want to achieve would be very helpful!

Thank you,
Paulius

2 Answers, 1 is accepted

Sort by
0
Paulius Putna
Top achievements
Rank 1
answered on 15 Mar 2012, 06:44 AM
I just noticed something else when trying to implement DragVisualProvider.

I used the example from Demos and thats the error I am getting:

No way to resolve conflict between "System.Windows.Controls.Toolkit.Internals, Version=4.0.5.0, Culture=neutral, PublicKeyToken=2c5c654d367bf4a7" and "System.Windows.Controls.Toolkit.Internals, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Windows.Controls.Toolkit.Internals, Version=4.0.5.0, Culture=neutral, PublicKeyToken=2c5c654d367bf4a7" arbitrarily.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3247: Found conflicts between different versions of the same dependent assembly.

public class DragVisualProvider : DependencyObject, IDragVisualProvider
    {
        public DataTemplate DraggedItemTemplate
        {
            get
            {
                return (DataTemplate)GetValue(DraggedItemTemplateProperty);
            }
            set
            {
                SetValue(DraggedItemTemplateProperty, value);
            }
        }
 
        public static readonly DependencyProperty DraggedItemTemplateProperty =
        DependencyProperty.Register("DraggedItemTemplate", typeof(DataTemplate), typeof(DragVisualProvider), new PropertyMetadata(null));
 
        public FrameworkElement CreateDragVisual(DragVisualProviderState state)
        {
            var visual = new DragVisual();
 
            var theme = StyleManager.GetTheme(state.Host);
            if (theme != null)
            {
                StyleManager.SetTheme(visual, theme);
            }
 
            visual.Content = state.DraggedItems.OfType<object>().FirstOrDefault();
            visual.ContentTemplate = this.DraggedItemTemplate;
 
            return visual;
        }
 
        public Point GetDragVisualOffset(DragVisualProviderState state)
        {
            return state.RelativeStartPoint;
        }
 
        public bool UseDefaultCursors { get; set; }
    }

I am using Silverlight 5 with 2012 Q1 RadControls.
0
Byock
Top achievements
Rank 1
answered on 05 Aug 2014, 09:40 AM
You need to install the Silverlight 5 SDK and the Silverlight 5 Tools for VS2010 SP1
Tags
DragAndDrop
Asked by
Paulius Putna
Top achievements
Rank 1
Answers by
Paulius Putna
Top achievements
Rank 1
Byock
Top achievements
Rank 1
Share this question
or