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
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

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

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;
}
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