I have a class that extends Appointment like so:
Dragging the AppointmentTaskVm from a ListBox to the ScheduleView causes the Copy and CopyFrom to fire multiple times. This results in the additional properties in the AppointmentTaskVm to loose thier values.
Subscribing to the AppointmentCreated event of the ScheduleView shows that the new AppointmentTaskVm additional properties are initialised with default values (instead of copying the values from the original AppointmentTaskVm).
public
class
AppointmentTaskVm : Appointment
{
private
int
_appointmentTaskId;
private
bool
_isBasketItem;
private
int
_position;
private
int
? _taskId;
public
int
AppointmentTaskId
{
get
{
return
_appointmentTaskId; }
set
{
_appointmentTaskId = value;
OnPropertyChanged(
"AppointmentTaskId"
);
}
}
public
bool
IsBasketItem
{
get
{
return
_isBasketItem; }
set
{
_isBasketItem = value;
OnPropertyChanged(
"IsBasketItem"
);
}
}
public
int
Position
{
get
{
return
_position; }
set
{
_position = value;
OnPropertyChanged(
"Position"
);
}
}
public
int
? TaskId
{
get
{
return
_taskId; }
set
{
_taskId = value;
OnPropertyChanged(
"TaskId"
);
}
}
public
override
IAppointment Copy()
{
var newAppointment =
new
AppointmentTaskVm();
newAppointment.CopyFrom(
this
);
return
newAppointment;
}
public
override
void
CopyFrom(IAppointment other)
{
var task = other
as
AppointmentTaskVm;
if
(task !=
null
)
{
AppointmentTaskId = task.AppointmentTaskId;
IsBasketItem = task.IsBasketItem;
Position = task.Position;
TaskId = task.TaskId;
}
base
.CopyFrom(other);
}
}
Dragging the AppointmentTaskVm from a ListBox to the ScheduleView causes the Copy and CopyFrom to fire multiple times. This results in the additional properties in the AppointmentTaskVm to loose thier values.
Subscribing to the AppointmentCreated event of the ScheduleView shows that the new AppointmentTaskVm additional properties are initialised with default values (instead of copying the values from the original AppointmentTaskVm).