How to Cancel Drop Operation from LayoutControlToolBox to LayoutControl

Environment

Product Version 2019.3.1023
Product RadLayoutControl for WPF

Description

How to cancel the drop operation from the LayoutControlToolBox to the RadLayoutControl.

Solution

To disallow the drop of a particular item from the toolbox to the RadLayoutControl you need to handle the drag and drop events of the DragDropManager and more specifically, the DragOver event.

The example below shows how to cancel the drop of a LayoutControlExpanderGroup but this can also be modified to work for any element.

public MainWindow() 
{ 
    InitializeComponent(); 
    DragDropManager.AddDragOverHandler(this.layout, OnLayoutControlDragOver, false); 
} 
 
private void OnLayoutControlDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) 
{ 
    var proxy = (LayoutControlHierarchicalNodeProxy)DragDropPayloadManager.GetDataFromObject(e.Data, "Telerik.Windows.Controls.LayoutControl.LayoutControlHierarchicalNodeProxy"); 
 
    if (proxy.OriginalItem is LayoutControlExpanderGroup) 
    { 
        e.Effects = DragDropEffects.None; 
        e.Handled = true; 
    } 
} 

See Also

In this article
Not finding the help you need? Improve this article