This is a migrated thread and some comments may be shown as answers.

Drop casting problem

3 Answers 97 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Christie Admin
Top achievements
Rank 1
Christie Admin asked on 09 Apr 2014, 06:48 PM
Hi,

I use a RadScheduleView with a collection of SpecialSlots (SpecialSlotsSource) and I'm trying to handle if the user drop an appointment on a compatible slot or not. My SpecialSlot (SpecialSlotsSource) was defined as follow:

public class MySpecialSlot : Slot
{
    public bool IsCompatible  { get; set; }
}

I implemented a CustomDragDrop behavior and in the override method Drop I'm trying to cast the "state.DestinationSlots.ElementAt(0) as MySpecialSlot" to check if the "IsCompatible" member is TRUE/FALSE the cast always return null.

Thank's
Alain

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 14 Apr 2014, 02:39 PM
Hello Alain,

This is expected result - special slots are actually over the regular slots, so when you drop an appointment, you receive in the DestinationSlots collection of the regular slots - they cannot be cast to the custom SpecialSlot class that you're using.

You could achieve the required approach by checking whether the SpecialSlots overlap with the destination slots with the help of the IntersectsWith method of the Slot class.

Additionally, In order to get the ScheduleView instance ( and after that its SpecialSlots) in the DragDropBehavior, you will need to use the ServiceProvider method of the DragDropState, please check the next snippet:

var scheduleView = state.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView;

Hope this helps.

Regards,
Yana
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Christie Admin
Top achievements
Rank 1
answered on 15 Apr 2014, 04:52 PM
Hi Yana,

I'm not sure the clearly understand what you said :(

Actually I have a collection of MySpecialSlot attached to the SpecialSource of my ScheduleView. MySpecialSlot contain a member "IsCompatible" which determine if the user can drop or not an appointment on it. So in my drag and drop behavior, on the CanDrop override method, I would like to test if the "IsCompatible" member is true to permit or not the drop function.

Can you tell me if I am in the field and if you have a better approach and if I'm ok how I can achieve this.

In the same way, in the CanDrop override method of my drag and drop behavior, I would like  to fire an event to the client to let hime add some logic, so when the drag operation start, I would like to fire my event only once to the client and tell him on over which MySpecialSlot he is. I don't want to fire my event on every mousemove if he still on the same MySpecialSlot.

Thank's
Alain
0
Yana
Telerik team
answered on 16 Apr 2014, 02:38 PM
Hello Alain,

As to the first requirement I just got another idea - you could set these special slots to be read-only - in this way the dropping of appointments over them will be forbidden, please check the ScheduleView Special and Read-Only Slots example at WPF Demos.
Please try it and let us know whether this approach is acceptable for you.

As to the second question - could you explain the exact use case in more details?  How could the client  add some logic?

I'm looking forward to your reply.

Regards,
Yana
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ScheduleView
Asked by
Christie Admin
Top achievements
Rank 1
Answers by
Yana
Telerik team
Christie Admin
Top achievements
Rank 1
Share this question
or