I have a case where the event handler that handles AppointmentSaving is invoked twice, but only every other time. It goes like this:
1) Find a calendar event
2) Drag the edge of the event to make it wider
3) Find a second event, and drag *that* event wider. AppointmentSaving will be called twice.
4) Repeat every other time. (2, 4, 6, 8, etc. with no end)
Here's the XAML setting up the event handler:
<i:EventTrigger
EventName="AppointmentSaving">
<vp:EventToCommandAction
PassEventArgsToCommand="True"
Command="{Binding HandleDowntimeSavingCommand, Mode=OneWay}" />
</i:EventTrigger>
Here's the event handler itself:
public ICommand HandleDowntimeSavingCommand => DelegateCommand.Create<AppointmentSavingEventArgs>(HandleDowntimeSaving);
internal void HandleDowntimeSaving(AppointmentSavingEventArgs eventArgs)
{
var downtime = (DowntimeViewModel)eventArgs.Appointment;
var numExceptionsRemoved = RemovePointlessExceptions(downtime);
var numExceptionsConverted = ConvertExceptionsToIsolatedDowntimes(downtime);
if (numExceptionsRemoved > 0 && numExceptionsConverted == 0)
{
eventArgs.Cancel = true;
}
}
DelegateCommand.Create is used in literally thousands of places; it's not the source of the bug. If I set a breakpoint on the first line of the event handler, it will be hit twice, but only on every second edit.