Drag & Drop from ItemsControl to RadTileView

3 posts, 0 answers
  1. Paulius Putna
    Paulius Putna avatar
    16 posts
    Member since:
    Feb 2010

    Posted 15 Mar 2012 Link to this post

    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. Paulius Putna
    Paulius Putna avatar
    16 posts
    Member since:
    Feb 2010

    Posted 15 Mar 2012 Link to this post

    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.
  3. DevCraft banner
  4. Byock
    Byock avatar
    3 posts
    Member since:
    Jan 2008

    Posted 05 Aug 2014 in reply to Paulius Putna Link to this post

    You need to install the Silverlight 5 SDK and the Silverlight 5 Tools for VS2010 SP1
Back to Top