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