I've got some weird behaviour going on, its probably something I've done, but I can't seem to work out whats going on.
I've set up two stack panels on my usercontrol, one called New Trip and one called New Misc Job - on initialize of the usercontrol I'm setting up the DragDropManager - actually all I'm doing is specifying the methods for DragIntialize like so :
DragDropManager.AddDragInitializeHandler(newTripDrag, NewTripDragInitialize);
DragDropManager.AddDragInitializeHandler(newJobDrag, NewMiscDragInitialize);
When the user drags one of the stackpanels onto the scheduleview, I've got some custom dragdropbehaviour going on, but at the end of the Drop method, it always calls base.Drop() and this is where the weird behaviour comes in, when I'm dragging a trip, it works perfectly and the trip is selected afterwards, but when I drag a misc job, it fires off the SelectedAppointment method with a null value which makes nothing selected afterwards.
Why would it be calling the SelectedAppointment for one and not the other, is there something I can change to stop this from happening, I've attached the Call Stack from the point of base.Drop() to Setting the SelectedAppointment for when I dragged a Misc Job (if that helps).
5 Answers, 1 is accepted
I did not manage to reproduce the described behavior, is it possible to send us some code snippets demonstrating the scenario?
Thanks in advance.
Regards,
Yana
Telerik by Progress
I've changed the code quite a bit since I posted this, but still getting issues when I try to select an item after I drop it from outside the grid. Effectively I've still got the DragDropManager handlers, heres an example :
private void NewTripDragInitialize(object sender, DragInitializeEventArgs args)
{
args.AllowedEffects = DragDropEffects.All;
var payload = DragDropPayloadManager.GeneratePayload(null);
ScheduleItem newTrip = new ScheduleItem(true, true, this.mainScheduleView.CurrentDate);
payload.SetData("DraggedData", newTrip);
args.Data = payload;
args.DragVisual = new ContentControl { Content = newTrip, ContentTemplate = LayoutRoot.Resources["DraggedTripTemplate"] as DataTemplate };
args.DragVisualOffset = new Point(args.RelativeStartPoint.X + 20, args.RelativeStartPoint.Y + 10);
}
This is then converted on my ScheduleViewDragDropBehaviour class and it runs through my overridden Drop code (which is quite long winded to post on here). Effectively, the Drop code goes off to our database to create the underlying data and creates the appointment, commits it, selects it and returns.
scheduleView.CreateNew(item);
scheduleView.Commit();
scheduleView.SelectedAppointment = item;
This does actually select the appointment, but the IsSelected property of the AppointmentItem does not appear to get set as my xml which controls a highlighting effect on the appointment does not appear to work until I actually click on the appointment :
<
ControlTemplate.Triggers
>
<
MultiTrigger
>
<
MultiTrigger.Conditions
>
<
Condition
Property
=
"IsSelected"
Value
=
"False"
/>
</
MultiTrigger.Conditions
>
<
Setter
TargetName
=
"tripSelector"
Property
=
"Effect"
Value
=
"{x:Null}"
/>
<
Setter
TargetName
=
"tripHolder"
Property
=
"Effect"
Value
=
"{x:Null}"
/>
</
MultiTrigger
>
</
ControlTemplate.Triggers
>
Thanks for the provided code.
I may be missing something, but the provided MultiTrigger would not be working for a selected Appointment, as the IsSelected Condition is set to False. Can you please clarify this?
Also, would it be possible for you to share some details on to which ControlTemplate the aforementioned MultiTrigger is applied?
Regards,
Stefan X1
Telerik by Progress
Hi Stefan,
The full xml for the AppointmentItem (which the ControlTemplate relates to) is as follows:
<
ControlTemplate
x:Key
=
"TripHorizontalControlTemplate"
TargetType
=
"scheduleView:AppointmentItem"
>
<
Grid
x:Name
=
"Root"
>
<!--NOTE: Add a tooltip-->
<
ToolTipService.ToolTip
>
<
ToolTip
Style
=
"{StaticResource TripToolTipStyle}"
/>
</
ToolTipService.ToolTip
>
<
Rectangle
x:Name
=
"tripSelector"
Width
=
"8"
Height
=
"8"
Fill
=
"Black"
HorizontalAlignment
=
"Center"
>
<
Rectangle.Effect
>
<
DropShadowEffect
ShadowDepth
=
"0"
Color
=
"Red"
Opacity
=
"0.8"
BlurRadius
=
"13"
/>
</
Rectangle.Effect
>
<
Rectangle.LayoutTransform
>
<
RotateTransform
Angle
=
"45"
/>
</
Rectangle.LayoutTransform
>
</
Rectangle
>
<
Line
x:Name
=
"tripHolder"
VerticalAlignment
=
"Stretch"
StrokeThickness
=
"3"
Stroke
=
"Black"
X1
=
"1"
Y1
=
"0"
X2
=
"1"
Y2
=
"{Binding ElementName=Root, Path=ActualHeight}"
HorizontalAlignment
=
"Center"
>
<
Line.Effect
>
<
DropShadowEffect
ShadowDepth
=
"0"
Color
=
"Red"
Opacity
=
"0.8"
BlurRadius
=
"13"
/>
</
Line.Effect
>
</
Line
>
</
Grid
>
<
ControlTemplate.Triggers
>
<
MultiTrigger
>
<
MultiTrigger.Conditions
>
<
Condition
Property
=
"IsSelected"
Value
=
"False"
/>
</
MultiTrigger.Conditions
>
<
Setter
TargetName
=
"tripSelector"
Property
=
"Effect"
Value
=
"{x:Null}"
/>
<
Setter
TargetName
=
"tripHolder"
Property
=
"Effect"
Value
=
"{x:Null}"
/>
</
MultiTrigger
>
</
ControlTemplate.Triggers
>
</
ControlTemplate
>
Effectively the ControlTemplate is just removing effects if the item is not selected (rather than applying the effects if it is selected).
Thank you for the update.
Unfortunately, based on the provided information I still cannot relate the reported behavior to an issue known to us. In order to avoid any misunderstandings, may I kindly ask you to open a new support thread and demonstrate your setup in a sample application so we can debug and hopefully, provide a solution?
Additionally, you can take a look at this blog post.
Thank you in advance for your cooperation.
Regards,
Stefan X1
Telerik by Progress