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

Drag drop from RadListBox to RadScheduleView with inherited appointments

6 Answers 85 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Santtu
Top achievements
Rank 1
Santtu asked on 03 Dec 2015, 10:14 AM

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;
    }
}

6 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 07 Dec 2015, 09:27 AM
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
0
Santtu
Top achievements
Rank 1
answered on 18 Jan 2016, 09:49 AM

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

0
Kalin
Telerik team
answered on 20 Jan 2016, 09:28 AM
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
0
Santtu
Top achievements
Rank 1
answered on 20 Jan 2016, 11:15 AM

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


 
0
Santtu
Top achievements
Rank 1
answered on 20 Jan 2016, 11:17 AM
I mean here https://dl.dropboxusercontent.com/u/42020186/customDragDrop2.zip
 
0
Kalin
Telerik team
answered on 25 Jan 2016, 08:58 AM
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
Tags
ScheduleView
Asked by
Santtu
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Santtu
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or