PropertyChanged on appointment properties

6 posts, 0 answers
  1. Ingrid
    Ingrid avatar
    4 posts
    Member since:
    May 2011

    Posted 06 Jul 2011 Link to this post

    Hello,

    I have an ObservableCollection of appointments. When you add or remove an appointment in code behind, the UI is changed, but when I change a property for the appointment nothing happens. I want to change the start / end date for some appointments in code behind, but when I do this, I can't see the changes directly on the screen. Is this normal behaviour or am I doing something wrong?

    Best regards,
    Jeffrey
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 06 Jul 2011 Link to this post

    I am pasting my response from your support ticket here, in case anyone else has the same problem:

    You need to call BeginEdit/Commit/Cancel methods before and after you change the appointment properties:

    foreach (var appointment in appointmentsToEdit)
    {
        this.scheduleView.BeginEdit(appointment);
        appointment.Start = new DateTime(...);
        ...
        this.scheduleView.Commit();
    }

    This "limitation" is because we use a IEditableCollectionView/ICollectionView as an internal data source and it requires the methods above to be called in order to refresh its content.

    Kind regards,
    Valeri Hristov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Jeffrey
    Jeffrey avatar
    5 posts
    Member since:
    Sep 2012

    Posted 07 Jul 2011 Link to this post

    Valeri,

    Thanks for your reply!
    I'm using Caliburn. This approach forces me to place code in my code behind file.
    Is there another way to do this in a clean MVVM way?

    Best regards,
    Jeffrey
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 07 Jul 2011 Link to this post

    Hi Jeffrey,

    Instead of calling BeginEdit/Commit you could remove/add the appointments from the source collection. The ListCollectionView internally does exactly the same thing when you call Commit, so I suppose there will be no performance hit.

    All the best,
    Valeri Hristov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. Ingrid
    Ingrid avatar
    4 posts
    Member since:
    May 2011

    Posted 23 Aug 2011 Link to this post

    Hello,

    After your reply I tried what you said and it worked, but now, after implementing the Q2 release I see that this functionality doesn't works anymore.
    I don't understand what's happening...
    Here is my code:

             IoC.Get<IEventAggregator>().Publish(new Messages.ScheduleMessage(tm, false));
             tm.Start = resizeTaakVM.TaakMiddel.Start;
             tm.End = resizeTaakVM.TaakMiddel.End;
             IoC.Get<IEventAggregator>().Publish(new Messages.ScheduleMessage(tm, true));

    ScheduleMessage class:

        public class ScheduleMessage
        {
            public ScheduleMessage(IAppointment appointment, bool commit)
            {
                Appointment = appointment;
                Commit = commit;
            }
     
            public IAppointment Appointment { getset; }
            public bool Commit { getset; }
        }

    Please help me on this one, I need to fix this quickly!

    Best regards,

    Jeffrey
  6. Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 26 Aug 2011 Link to this post

    Hi Ingrid,

    We are not able to reproduce the problem locally.You can find a sample project attached that works as expected at our side. Is it possible to isolate the issue in small problem so we can test it locally?

    Greetings,
    Rosi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top