Drop casting problem

4 posts, 0 answers
  1. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 09 Apr 2014 Link to this post

    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
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 Apr 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 15 Apr 2014 in reply to Yana Link to this post

    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
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 Apr 2014 Link to this post

    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.

     
Back to Top