AppointmentSaving is invoked twice, but only on every other edit

2 posts, 0 answers
  1. Rian
    Rian avatar
    1 posts
    Member since:
    Aug 2017

    Posted 25 Aug Link to this post

    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.

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    603 posts

    Posted 30 Aug Link to this post

    Hello Rian,

    I tried to reproduce the behavior you've described but was unable to do so. I'm attaching the sample project I've used for the purpose. Can you please have a look at it and let me know how I can modify it in order to replicate the aforementioned issue?

    I'm looking forward to your reply.

    Regards,
    Dilyan Traykov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top