
I would like to bind an items datacontext to a property of my DragDropBehavior but your abstract class inherits from DependencyObject instead of FrameworkElement so it doesn't work.
Can you change this class:
public abstract class DragDropBehavior<TState> : DependencyObject, IDragDropBehavior<TState> where TState : DragDropState
To this in the future:
public abstract class DragDropBehavior<TState> : FrameworkElement, IDragDropBehavior<TState> where TState : DragDropState
3 Answers, 1 is accepted
You can accomplish that by implementing the IDragDropBehavior interface and inheriting from FrameworkElement, which should give you the functional requirements that you have.
Let me know if you need any help doing it!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Do you have an example that shows how to apply a behavior from a Custom Class that implements IDragDropBehavior interface?
Also would I lose the built in Adorner logic, or does that come along for free?
Thanks,
Jason
Unfortunately the Generig DragDropBehavior class cannot be used directly in XAML this is a limitation of the framework itself. To use it there you have to inherit from the generic class and use the derived class definition instead.
As to the adorner logic, I am not sure to what you are referring exactly. Can you clarify?
Looking forward to your reply!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
This is a very old issue, but I'm finding myself in the same spot. Has there been any changes to the Telerik library that would make this possible now? I have a simple class derived from `ListBoxDragDropBehavior` with a DependencyProperty that I need to bind to (see the two screenshots of the basic setup below).
https://github.com/punker76/gong-wpf-dragdrop
Hey guys, what you are doing sounds meaningful, so I've logged a new request in our feedback portal to change the parent class of the behavior to Freezable. This will allow automatic inheritance of the data context in XAML and also the usage of ElementName binding.
Felix, in the meantime, an idea that you can explore is to manually define the binding in C#. This will allow you to set the Source of the Binding object.
public MainWindow()
{
InitializeComponent();
var behavior = (SessionItemDragDropBehavior)this.listBox.DragDropBehavior;
var binding = new Binding(nameof(MyViewModel.DropAction)) { Source = this.DataContext };
BindingOperations.SetBinding(behavior, SessionItemDragDropBehavior.OnDropActionProperty, binding);
}
I've attached a sample project showing this. I hope it helps.
And Jason, I am sorry that we needed so much time to wrap our heads around the problem and log it for improvement.