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

DragVisual "effect" icon?

5 Answers 371 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 16 Jan 2017, 05:55 PM

From the drag drop examples on the site, the dragging and dropping within and between grid views is more or less working how we want. But I would like to change the icon in the visual associated with the "effect" and I can't seem to figure out how and where to do it. We have a content template but that only affects the rest of the visual and not the "effect" portion of it.

I tried inheriting from the DragVisual but there are so many overridable things within I can't tell what is needed to be done. One thing however that was particularly interesting, is that when I inherit from the DragVisual but do not override anything within, the "move" icon is gray instead of blue.

I am trying to achieve displaying a delete icon if the user drags an item outside of the grid to indicate that the item will be removed rather than the "no" icon which implies that the action will have no result. Please advise if there is a simpler way to do this.

5 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 19 Jan 2017, 01:59 PM
Hi Steve,

I am not sure which demos you are referring to, but I guess you have checked the DragDrop - Tree To Grid one from our WPF Demos Application.

It would not be possible to modify the icons while using the DragVisual element. However, you can assign a custom control or whatever element you desire to . argument in the OnDragInitialize event:

private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            . . .
            //set the DragVisual to whatever element you desire
            e.DragVisual = new TextBlock() { Text = "Some Text" };
            . . .
        }

Would this work for you?

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Darren
Top achievements
Rank 1
answered on 21 Feb 2017, 02:57 PM
Is it possible to hide that feedback icon at all and only display the content we add to DragVisual?
0
Stefan Nenchev
Telerik team
answered on 22 Feb 2017, 11:18 AM
Hello Darren,

In order to avoid providing you with misleading information, can you confirm which exactly icon you are referring to? Please point out the example that you are using and the action in which the icon appears so we can advise you.

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Darren
Top achievements
Rank 1
answered on 22 Feb 2017, 12:16 PM

 

 

 

Hi,

I've attached an image pointing out the icon and also pasted our code below.  

Darren

 

private void OnDragInitialize(object sender, DragInitializeEventArgs dragInitializeEventArgs)
{
    if (_currentFixtureViewModel == null) return;
 
    DropIndicationDetails details = new DropIndicationDetails();
    List<ProductSimpleVM> productsVM = new List<ProductSimpleVM>();
 
    var selectedCells = (sender as RadGridView).SelectedCells;
    if (!selectedCells.Any()) return;
     
    foreach (var cell in selectedCells)
    {
            var prodVM = cell.Item as ProductSimpleVM;
            if (prodVM == null) continue;
            if (productsVM.FirstOrDefault(alreadyAddedVM => alreadyAddedVM.EAN == prodVM.EAN) != null) continue;
 
            ((ProductSimpleVM)cell.Item).Scaling = _currentFixtureViewModel.ScalingParams;
            productsVM.Add((ProductSimpleVM)cell.Item);
    }
    if (selectedCells.Count == 0) return;
        details.CurrentDraggedItems = productsVM;
 
    IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);
 
    dragPayload.SetData(Constants.WarehouseProductDragFormatName, productsVM);
    dragPayload.SetData("DropDetails", details);
 
    dragInitializeEventArgs.Data =  dragPayload;
 
    dragInitializeEventArgs.DragVisual = new DragVisual()
    {
        Content = details,
        ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
    };
    var productHeightOffset = selectedCells.Max(p => ((ProductSimpleVM)p.Item).Height) * _currentFixtureViewModel.ScalingParams.Scale;
 
    Point dragVisualOffset = new Point(dragInitializeEventArgs.RelativeStartPoint.X, dragInitializeEventArgs.RelativeStartPoint.Y - productHeightOffset);
    dragInitializeEventArgs.DragVisualOffset = dragVisualOffset;
    dragInitializeEventArgs.AllowedEffects = DragDropEffects.All;
}
0
Stefan Nenchev
Telerik team
answered on 24 Feb 2017, 08:52 AM
Hello Darren,

As advised in my original answer, you can set a control of your choice to the DragVisual parameter in the OnDragInitialize event. Please check the Set Drag Visual article from our documentation page. 

Regards,
Stefan Nenchev
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
DragAndDrop
Asked by
Steve
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Darren
Top achievements
Rank 1
Share this question
or