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

Drag cue template

0 Answers 21 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 17 Jan 2014, 11:24 AM
Dear Telerik Team!

Can you please help me getting custom drag cue please? I searched everywhere but without success. This is my xaml:

<telerikControls:RadGridView Grid.ColumnSpan="2"  ...
                
                                    
           <telerikControls:RadGridView.Resources>
                <DataTemplate x:Key="DraggedItemTemplate">
                    <StackPanel Orientation="Horizontal" Margin="2">
                        <TextBlock Text="test" FontWeight="Bold" />
                    </StackPanel>
                </DataTemplate>
            </telerikControls:RadGridView.Resources>
 
            <planerView:RadGridViewDragDrop.DragVisualProvider>
                <!--<planerView:RadGridViewItemDragVisualProvider>                 
                </planerView:RadGridViewItemDragVisualProvider>-->
                <telerikDragDropBehaviors:ScreenshotDragVisualProvider></telerikDragDropBehaviors:ScreenshotDragVisualProvider>
            </planerView:RadGridViewDragDrop.DragVisualProvider>
 
        </telerikControls:RadGridView>

and that is my RadGridViewItemDragVisualProvider code:

public class RadGridViewItemDragVisualProvider : 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(RadGridViewItemDragVisualProvider), new PropertyMetadata(null));
 
        public FrameworkElement CreateDragVisual(DragVisualProviderState state)
        {
            var visual = new DragVisual();
 
            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; }
    }

But it doesn't work. DraggedItemTemplate is always null. I would be very grateful for any help in that matter.

Very best regards
Krzysztof Ka┼║mierczak

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Krzysztof
Top achievements
Rank 1
Share this question
or