I've noticed strange thing
if i start drag operation of button from right tide of button arrowCue is next to VisualCue (left picture)
If I start from left side - arrowCue shifted (right picture)
Any ideas?
3 Answers, 1 is accepted
The behavior you are experiencing is indeed strange? May I ask you to provide more detailed information about the exact drag and drop implementation you are using? Do you set a DragCueOffset at the beginning of the drag operation?
Looking forward to hearing from you!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
Button
Content
=
"ccccccccccc"
telerik:RadDragAndDropManager.AllowDrag
=
"True"
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"51,12,0,0"
Name
=
"button1"
VerticalAlignment
=
"Top"
Width
=
"75"
/>
<
ListBox
telerik:RadDragAndDropManager.AllowDrop
=
"True"
Height
=
"87"
HorizontalAlignment
=
"Left"
Margin
=
"90,0,0,41"
Name
=
"listBox1"
VerticalAlignment
=
"Bottom"
Width
=
"236"
/>
</
Grid
>
and code behind:
public
MainPage()
{
InitializeComponent();
RadDragAndDropManager.AddDragQueryHandler(
this
, OnDragQuery);
RadDragAndDropManager.AddDropQueryHandler(
this
, OnDropQuery);
}
private
void
OnDropQuery(
object
sender, DragDropQueryEventArgs e)
{
e.QueryResult =
true
;
}
private
void
OnDragQuery(
object
sender, DragDropQueryEventArgs e)
{
if
(e.Options.Status == DragStatus.DragQuery)
{
e.QueryResult =
true
;
e.Options.DragCue = RadDragAndDropManager.GenerateVisualCue(e.Options.Source);
var arrowCue = RadDragAndDropManager.GenerateArrowCue();
e.Options.ArrowCue = arrowCue;
}
e.Handled =
true
;
}
Test project is here:
https://skydrive.live.com/redir?resid=17FEEB61AFE2DBEB!14919&authkey=!AH3czBO5Lq7skuA
The reason for the issue is that you are using the GenerateVisualCue method, which basically creates an empty cue with the same size and margins that the given parameter has. Therefore the buttons margin is applied to the VisualCue resulting in the experienced behavior.
Here is how you can fix the issue:
private
void
OnDragQuery(
object
sender, DragDropQueryEventArgs e)
{
if
(e.Options.Status == DragStatus.DragQuery)
{
e.QueryResult =
true
;
var cue = RadDragAndDropManager.GenerateVisualCue(e.Options.Source);
cue.Margin =
new
Thickness(0);
e.Options.DragCue = cue;
var arrowCue = RadDragAndDropManager.GenerateArrowCue();
e.Options.ArrowCue = arrowCue;
}
e.Handled =
true
;
}
Hope this helps! Let me know if there is anything more I can help you with! All the best,
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>