
For example, I tried something like this:
<Style TargetType="telerik:GridViewRow" x:Key="OrderItemStyle"> |
<Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" /> |
<Setter Property="dragDrop:RadDragAndDropManager.DropQueryEvent" Value="OnRowDropQuery" /> |
<Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" /> |
</Style> |
but the DropQueryEvent is not recognized as being available in the RadDragAndDropManager.
Any ideas?
20 Answers, 1 is accepted
I am sorry for the delayed reply!
Yes, event handlers can be assigned in xaml. The correct syntax in WPF is:
<
Window.Resources
>
<
Style
TargetType
=
"ListBoxItem"
x:Key
=
"OrderItemStyle"
>
<
Setter
Property
=
"dragDrop:RadDragAndDropManager.AllowDrop"
Value
=
"True"
/>
<!--<Setter Property="dragDrop:RadDragAndDropManager.DropQueryEvent" Value="OnRowDropQuery" />-->
<!--Handler in a setter:-->
<
EventSetter
Event
=
"dragDrop:RadDragAndDropManager.DropQuery"
Handler
=
"OnRowDropQuery"
/>
<
Setter
Property
=
"dragDrop:RadDragAndDropManager.AllowDrag"
Value
=
"True"
/>
</
Style
>
</
Window.Resources
>
<
Grid
>
<!--Handler in xaml:-->
<
ListBox
dragDrop:RadDragAndDropManager.DragQuery
=
"OnRowDropQuery"
/>
</
Grid
>
Hopefully this will help you,
Sincerely yours,
Miroslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

thanks
mark

Here's some links:
http://geekswithblogs.net/HouseOfBilz/archive/2009/08/27/adventures-in-mvvm-ndash-binding-commands-to-any-event.aspx
http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/
Regards
James

thanks
mark

CommandParamerter="{Binding
ElementName=radDataFilter, Path=FilterDescriptors}"
Saying that the parameter should be superfluous because you're telling the ViewModel to do something with data that has already been stored on it as it is a property or colleciton of the ViewModel that is bound to by another control.
James

RadDragAndDropManager.AddDragQueryHandler(this, OnDragQuery);
RadDragAndDropManager.AddDragInfoHandler(this, OnDragInfo);
RadDragAndDropManager.AddDropQueryHandler(this, OnDropQuery);
RadDragAndDropManager.AddDropInfoHandler(this, OnDropInfo);
I know how to use the EventToCommand in MVVM Light, but in the Telerik example, the above code runs in the "View"...I'm not sure what I set the EventToCommands to or what I bind them to using MVVM Light. That is, do I add them to the Layout Root? The Listbox I am dragging from, etc...If I'm not using MVVM(light), I understand your example with Delegates, etc...I just get confused when I'm trying to implement your controls into this pattern.
thanks
mark

EventCommandBehavior.EventName="DropInfo" EventCommandBehavior.Command="{Binding DropInfoCommand}" EventCommandBehavior.CommandParameter="{Binding ElementName=whichevercontrolyouwant,Path=whicheverproperty}"
or
EventCommandBehavior.CommandParameter="{Binding whichevermodelpropertyyouwant}"
James

Mark
James pointed the right solution in this case. You can create attached behavior that will attach to the specified events and invoke the commands as needed.
Since you are using MVVM light I can also suggest the approach used in the attached example. It demonstrate how to use directly EventToCommand action provided by the toolkit. The project introduces RoutedEventTrigger class that allows you to connect directly to the routed events that does have the corresponding regular event.
Kind regards,
Tsvyatko
the Telerik team

protected virtual void SubscribeToEvent()
{
var routedEvent = EventManager.GetRoutedEventsForOwner(this.EventOwnerType).Where(c => c.Name == this.EventName).First();
if (routedEvent != null)
{
Type handlerType = routedEvent.HandlerType;
var del = Delegate.CreateDelegate(handlerType, this, "OnEventInvoked");
if (this.AssociatedObject is UIElement)
{
((
UIElement)this.AssociatedObject).AddHandler(routedEvent, del);
}
}
}
How do I change the line with the EventManager.GetRoutedEventsForOwner method? I found a Telerik version, but it looks fairly different and I'm not sure how to use it.
thanks
mark
Please, excuse us for the misunderstanding. I had prepared the sample application in WPF since this thread is in the WPF section.
I have modified the example to work in Silverlight environment. Please have a look and let me know if this works for you.
All the best,
Tsvyatko
the Telerik team

mark

Hi
I am trying to implement drag and drop functionality using Telerik controls using the MVVM pattern.
I have an example of it working with the MVVM Light Toolkit as follows:
<i:Interaction.Triggers> <local:DragDropQueryRoutedEventTrigger EventName="DragQuery" EventOwnerType="{x:Type telerik:RadDragAndDropManager}"> <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding Command}" PassEventArgsToCommand="true"/> </local:DragDropQueryRoutedEventTrigger> </i:Interaction.Triggers>
I would like to do something similar using Caliburn Micro as follows
<i:EventTrigger EventName="DragQuery"> <cal:ActionMessage MethodName="DragQuery" > <cal:Parameter Value="$eventArgs" /> </cal:ActionMessage> </i:EventTrigger>
The problem with the above code is that Caliburn Micro is looking for the DragQuery event on my RadGridView control, but the event is actually being raised on the RadDragAndDropManager as specified in the EventOwnerType property from the MVVM Light Toolkit code block.
Is there some way of telling the ActionMessage to go look for the event on a specific Type or am I missing something obvious?
Regards
Dirk


This is in silverlight using the MVVM Light Toolkit.
<
StackPanel
x:Name
=
"ExportDropPanel"
Height
=
"100"
Width
=
"100"
Background
=
"Blue"
Margin
=
"5"
telerik:RadDragAndDropManager.AllowDrop
=
"True"
>
<
i:Interaction.Triggers
>
<
dblocal:DropInfoRoutedEventTrigger
EventName
=
"DropInfo"
>
<
cmd:EventToCommand
Command
=
"{Binding ExportOnDropInfoCommand, Mode=OneWay}"
PassEventArgsToCommand
=
"True"
/>
</
dblocal:DropInfoRoutedEventTrigger
>
<
dblocal:DropQueryRoutedEventTrigger
EventName
=
"DropQuery"
>
<
cmd:EventToCommand
Command
=
"{Binding ExportOnDropQueryCommand, Mode=OneWay}"
PassEventArgsToCommand
=
"True"
/>
</
dblocal:DropQueryRoutedEventTrigger
>
</
i:Interaction.Triggers
>
</
StackPanel
>
And the following is the code in the viewmodel:
ExportOnDropInfoCommand = new RelayCommand<
DragDropEventArgs
>(OnDropInfo);
ExportOnDropQueryCommand = new RelayCommand<
DragDropQueryEventArgs
>(OnDropQuery);
Thanks
Steve
Since treeview handles some of the Drag Drop events internally the subscription to the events should listen for handled ones as well.
Here is sample code how to achieve this:
protected override void SubscribeToEvent()
{
this.AssociatedObject.AddHandler(RadDragAndDropManager.DropQueryEvent,new EventHandler<
DragDropQueryEventArgs
>(OnEventInvoked), true);
}
Tsvyatko
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Thanks for the quick reply. It works great.
Thanks,
Steve

I tested the example 'mvvmlight2.zip' (Posted on Sep 23, 2010 , Drag&Drop with MVVMLight) but i need this with .net 3.5 (not .net 4.0).
When i change to 3.5, it doesn't work. The error message is: Can't find DragDrop Event.
Can everybody help?
I have modified the project to work with WPF3.5 please have alook and let us know if you have any further quetstions.
Regards,Tsvyatko
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
