Drag drop from RadListBox to RadScheduleView with inherited appointments

7 posts, 0 answers
  1. Santtu
    Santtu avatar
    4 posts
    Member since:
    Apr 2013

    Posted 03 Dec 2015 Link to this post

    Hi,

    I have problems when drag dropping inherited appointments from RadListBox to RadScheduleView. When the inherited class ProtocolChildAppointment (as below) is dropped from radListBox to scheduleview its a ProtocolAppointment class not the intented inherited class. I have tried to override Drop-function without success. Everything looks like its dropping a ProtocolChildAppointment  in the ConvertTo, ConvertDraggedData and Drop -functions.

    public class ProtocolAppointment : Appointment
    {
        public ProtocolAppointment()
            : base()
        {
        }
        // code...
        public override IAppointment Copy()
        {
            var newAppointment = new ProtocolAppointment();
            newAppointment.CopyFrom(this);
            return newAppointment;
        }
    }

    public class ProtocolChildAppointment : ProtocolAppointment
    {
        public ProtocolChildAppointment()
            : base()
        {
        }
        //code...
        public override IAppointment Copy()
        {
            var newAppointment = new ProtocolChildAppointment();
            newAppointment.CopyFrom(this);
            return newAppointment;
        }
    }

    class ProtocolScheduleViewDragDropBehavior : Telerik.Windows.Controls.ScheduleViewDragDropBehavior
    {
        public override IEnumerable<IOccurrence> ConvertDraggedData(object data)
        {
            if (DataObjectHelper.GetDataPresent(data, typeof(ProtocolAppointment), true))
            {
                return ((IEnumerable)DataObjectHelper.GetData(data, typeof(ProtocolAppointment), true)).OfType<IOccurrence>();
            }
            return base.ConvertDraggedData(data);
        }

        public override void Drop(Telerik.Windows.Controls.DragDropState state)
        {
            // here all stil looks like its dropping ProtocolChildAppointment
            base.Drop(state);
        }

    }

    class ProtocolAppointmentConverter : DataConverter
    {
        public override string[] GetConvertToFormats()
        {
            return new string[] { typeof(PetErpUIClient.ProtocolAppointment).AssemblyQualifiedName };
        }

        public override object ConvertTo(object data, string format)
        {
            if (DataObjectHelper.GetDataPresent(data, typeof(ProtocolAppointment), false))
            {
                var payload = (IEnumerable)DataObjectHelper.GetData(data, typeof(ProtocolAppointment), false);
                if (payload != null)
                {
                    List<PetErpUIClient.ProtocolAppointment> apps = new List<PetErpUIClient.ProtocolAppointment>();
                    apps.AddRange(payload.OfType<PetErpUIClient.ProtocolAppointment>());
                    return apps;
                }
            }
            return null;
        }
    }

  2. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 07 Dec 2015 Link to this post

    Hello Santtu,

    Using the provided description and our SDK example of dropping items from ListBox to ScheduleView we tried to reproduce the observed by you behavior but it seems everything is working as expected on our side. We suggest you to check the sample from our SDK Repository that demonstrates how a custom appointment is dragged from ListBox to RadScheduleView:
    https://github.com/telerik/xaml-sdk/tree/master/ScheduleView/CustomDragDropBehavior

    Attached you could also find the sample modified in order to reproduce your behavior - could you please, check it and try to reproduce the observed by you issue and send the sample back to us? Thus we could be able to continue our investigation and provide you with a prompt solution.

    Hope this helps.

    Regards,
    Nasko
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Santtu
    Santtu avatar
    4 posts
    Member since:
    Apr 2013

    Posted 18 Jan in reply to Nasko Link to this post

    Hi,

     I was able to reproduce the problem with your sample by changing the type of observable collection holding all the appointments (sheduleview's AppointmentSource) from CustomChildAppointment to CustomAppointment. I have more than one inherited custom child appointment which should be in the same container (AppointmentSource).

    I can't attach my sample here because allowed extensions are .gif, .jpg, .jpeg, .png

    Regards,

    Santtu

  5. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 20 Jan Link to this post

    Hello Santtu,

    Using the ConvertDraggedData method of the ScheduleViewDragDropBehavior you would be able to convert the dragged item into the needed type. I tried changing the Appointments collection type to CustomAppointment - however couldn't notice anything wrong afterwards. Can you explain the exact steps and the expected/actual result using our sample project.

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  6. Santtu
    Santtu avatar
    4 posts
    Member since:
    Apr 2013

    Posted 20 Jan in reply to Kalin Link to this post

    Hi,

     Here is the modified sample http://www.telerik.com/forums/drag-drop-from-radlistbox-to-radscheduleview-with-inherited-appointments#cNRaiuO90EWfFMlY8AIEIw

    When I drag the customChildAppointments to the calendar, they appear as customAppointments.

    Regards,

    Santtu


     
  7. Santtu
    Santtu avatar
    4 posts
    Member since:
    Apr 2013

    Posted 20 Jan in reply to Santtu Link to this post

    I mean here https://dl.dropboxusercontent.com/u/42020186/customDragDrop2.zip
     
  8. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 25 Jan Link to this post

    Hello Santtu,

    Thanks for the sample project. We managed to observe the explained behavior, however this is expected due to the implementation of the control and its drag drop logic. The control uses internally IEditableCollectionView
    and on drop calls its AddNew() method that creates new instance of the type the collection is and add it to the AppointmentsSource. So what I can suggest instead would be use a single appointment type, but with a property that identifies and appointment being parent or child (enum property). Also please note the custom Appointment class should be implemented as shown in the following article:
    http://docs.telerik.com/devtools/wpf/controls/radscheduleview/features/appointments/custom-appointment#creating-a-custom-appointment-class

    Hope this helps.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready