Appointment Start/End updated from VM

10 posts, 0 answers
  1. Cameron
    Cameron avatar
    11 posts
    Member since:
    May 2015

    Posted 14 Aug 2015 Link to this post

    Hey,

     I have a button that changes my appointment start and end times between UTC and Local to a slected Timezone. The button updates the appointments correctly but I cannot get the UI to update accordingly. I have noticed that a forum post from two years ago address' this problem but it did not look like a solution was found as I too am using MVVM. 

    Any suggestions?

     Thanks,

    Cameron

  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 17 Aug 2015 Link to this post

    Hi,

    I suggest you edit the appointment's properties using the BeiginEdit() and Commit() methods as described in our documentation.


    Another way to refresh the UI is by resetting the template as follows:
    System.Windows.Controls.ControlTemplate template = this.ScheduleView.Template;
      this.ScheduleView.Template = null;
      this.ScheduleView.Template = template;

    Hope this helps.

    Regards,
    Rosi
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Cameron
    Cameron avatar
    11 posts
    Member since:
    May 2015

    Posted 17 Aug 2015 Link to this post

    Hey, 

     Thanks for that. Can I ask, why do the Appointments not update when I change the Start and Finish time in my viewmodel? I basically set the new Start and Finish time and call and OnPropertyChanged event against the observable collection but it does not update.

     Thanks

    Cameron

  5. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 20 Aug 2015 Link to this post

    Hello,

    Appointment class uses an internal backup storage used for canceling the edit of the properties and implement IEditableObject interface. That is why you need to call the Commit method in order to update the default values of the appointment class.


    If you implement a custom appointment and add regular Dependency properties for example  CustomStart and CustomEnd and use them in the template changing them on propertychange will affect the UI immediately.

    However in this case canceling the change of the property via UI will not be possible.

    Regards, Rosi
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Andrey
    Andrey avatar
    7 posts
    Member since:
    Jun 2012

    Posted 01 Feb Link to this post

    Hi,

    Can you tell a little more about custom CustomStart and CustomEnd properties. Will it instead old (Start/End) properties? And how to use them in template. Maybe you can give an example. Because, as I understood from the posts above, it is not possible to update view (start/end of appointments in scheduler) without direct manipulations with scheduler (BeiginEdit() and Commit()) that is not good solution according to MVVM.

    Best regards,
    Andrey

  7. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 02 Feb Link to this post

    Hello,

    Example of custom properties added to appointment and its template can be found here and here
    Also please follow our documentation about Custom Appointment for more details.

    Hope this helps.

    Regards,
    Rosi
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Andrey
    Andrey avatar
    7 posts
    Member since:
    Jun 2012

    Posted 03 Feb in reply to Rosi Link to this post

    Hi,

    Thank you for the answer. I understood all about custom appointments.

    But the main question still remains: is there any way to update start and end of appointments in scheduler in the View without having access to this scheduler? or start and end of the appointment in in scheduler strictly attached to Start / End of IAppointment? I ask this because I do not have access to the View (so I can't use BeginEdit and Commit) and there is a need to update start and end of the appointments in scheduler.

    Best regards,
    Andrey

  9. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 05 Feb Link to this post

    Hello,

    Using the BeginEdit() and Commit() methods is the approach that I suggest you to use.
    However another thing that you can try is to  update the properties of appointments without calling these methods and try removing the edited appointment and adding it again in the appointments source collection. This should do the trick.

    Hope this helps.

    Regards,
    Rosi
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  10. Cameron
    Cameron avatar
    11 posts
    Member since:
    May 2015

    Posted 01 Mar Link to this post

    Hey,

    Have you made sure that you have implemented the Copy() and CopyFrom() function in your custom appointment class?

    public override void CopyFrom(IAppointment other)
    {
        AppointmentModel appointment = other as AppointmentModel;
        if (appointment != null)
        {
            this.Start = appointment.Start;
            this.End = appointment.End;
        }
        base.CopyFrom(other);
    }

    Then by updating the Start and End time of the appointment should refresh on the ScheduleView. 

    Regards,

    CM

  11. Andrey
    Andrey avatar
    7 posts
    Member since:
    Jun 2012

    Posted 06 Apr Link to this post

    Thanks a lot for answers. Everything works fine.

    Regards,
    Andrey

Back to Top
UI for WPF is Visual Studio 2017 Ready