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
7 Answers, 1 is accepted
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!
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
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!
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 { get; set; } public bool Commit { get; set; } }
Please help me on this one, I need to fix this quickly!
Best regards,
Jeffrey
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 >>
i am very disappointed that we must use old technical ways for refreshing of the subject in the view.
that is not the sense of mvvm and really bad in a time of multithreading, when you refresh the data
in the background.
Can you please tell me what exactly you mean by old technical ways of refreshing the subject in the view? And also how would you prefer doing this?
Regards,
Martin Ivanov
Progress Telerik