Refresh appointment duration

2 posts, 1 answers
  1. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 04 Sep 2013 Link to this post

    I've added a Duration property to a custom appointment (based loosely on one of the Telerik demos) but I'd like to have it refresh in the EditAppointment dialog whenever the Start or End time changes. I've added what i thought would be the appropriate override to my custom Appointment:

    private string _apptDur;
    public string ApptDur
    {
        get
        {
            TimeSpan t = TimeSpan.FromMinutes((this.End - this.Start).TotalMinutes);
            this._apptDur = "";
            if (t.Days > 1)
                this._apptDur += t.Days.ToString() + " days ";
            else if (t.Days == 1)
                this._apptDur += "1 day ";
            if (t.Hours > 1)
                this._apptDur += t.Hours.ToString() + " hours ";
            else if (t.Hours == 1)
                this._apptDur += "1 hour ";
            if (t.Minutes > 0)
                this._apptDur += t.Minutes.ToString() + " min";
     
            return _apptDur;
        }
    }
     
    protected override void OnPropertyChanged(string propertyName)
    {
        base.OnPropertyChanged(propertyName);
     
        if (propertyName == "Start" || propertyName == "End")
        {
            this.OnPropertyChanged("ApptDur");
        }
    }

    However, I'm not seeing a change in the dialog when times change. Those DatePicker controls are bound in the template to ActualStart and ActualEnd. Where are those defined and should I be watching those instead of Start and End? 
  2. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 05 Sep 2013 Link to this post

    Hi Art,

    The appointment properties are not updated in EditAppointmentDialog as we intentionally do not listen to their PropertyChanged event - it is implemented by design like this as we do not want to update the properties before the dialog is confirmed.

    However, you can work-around the behavior by following the approach demonstrated in the following Code Library:
    http://www.telerik.com/community/code-library/silverlight/scheduleview/how-to-create-advanced-custom-editapointmentdialog.aspx

    I hope this helps.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top