AppointmentSaving is fired twice when using custom class for appointments

5 posts, 2 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 19 Jan 2011 Link to this post

    Below I have pasted an approximation of the custom class I am using for the appointments. When I create and edit appointments using this custom class, the AppointmentSaving event is fired twice in succession. When using the default Appointment class, this does not happen. Is there anything in my class that might cause this behaviour, or is it a bug?

    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls.ScheduleView;
     
    namespace SilverlightApplication1
    {
        public class GLSAppointment : Appointment
        {
            public GLSAppointment()
                : base()
            {
                MyProperty = "SomeValue";
            }
     
            public string MyProperty { get; set; }
     
            public override IAppointment Copy()
            {
                var copy = new GLSAppointment();
                copy.CopyFrom(this);
     
                copy.MyProperty = this.MyProperty;
     
                return copy;
            }
     
            public override void CopyFrom(IAppointment other)
            {
                base.CopyFrom(other);
                MyProperty = (other as GLSAppointment).MyProperty;
            }
        }
    }
  2. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 21 Jan 2011 Link to this post

    Hello Henrik,

     I tried your code at my side and it works as expected. What I suspect is that there is anther problem in your code that interferes somehow with the custom appointment and cause the problem. Could you please open a support ticket and send us a sample project that reproduces the problem? This way we will be able to investigate what causes the issue.

    Moreover I found two problems in your code that shouldn't cause the problem, but you could fix them:
    - In both methods Copy and CopyFrom you set the MyProperty property and you don't need to do this in the Copy method as you call the CopyFrom method in it
    - The way you implement the custom property (an automatic property) is not correct - it will not support editing in a transaction. For more information how to implement custom appointments you could refer to the following blog post http://blogs.telerik.com/blogs/posts/10-11-25/how_to_create_custom_appointments_and_custom_appointment_dialog_in_telerik_scheduleview.aspx or the following help article http://www.telerik.com/help/wpf/radscheduleview-features-appointments-custom-appointment.html.

    Hope this helps!

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 21 Jan 2011 Link to this post

    Ok, it looks like I have to make some modifications to my custom class then. Thanks for that. And I will see what I can do about a sample project.
  5. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 02 Feb 2011 Link to this post

    Finally I have put together a sample project. After investigating a little further it seems that this did not have to do with the custom class after all. To reproduce the bug in the sample project:
    Create an appointment and select OK (it does not matter what data you enter). Watch the output window for my Debug.WriteLine. AppointmentSaving will now be fired once.
    Create another appointment. This time the event is fired twice.
    Create yet another appointment. Now the event is fired once.
    If you keep going the event is only fired once. So it seems that it is only when you create the 2nd appointment that the event is fired twice.

    Sample project:
    http://cid-cc43a90a79374ebd.office.live.com/self.aspx/Public/RadScheduleViewBug01.zip

    Best regards,
    /Henrik
  6. Answer
    George
    Admin
    George avatar
    1332 posts

    Posted 07 Feb 2011 Link to this post

    Hi Henrik,

     
    Thank you for sending us this project, it helped a lot. This problem happens only when you have empty AppointmentsSource (no appointments) and when you create the second appointment. 

    There is a bug in the framework and we use a workaround until it is fixed. Unfortunately, this fires the second AppointmentSaving event. We will do our best to fix this problem in our future releases. I am glad to update your telerik points.

    Best wishes,
    George
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top
DevCraft banner