Hi,
I am using a DataTemplateSelector and DataTemplates to show and interact with Custom Appointments in the schedule.
The Custom Appointment has a field called BindingItem added which holds a reference to my data.I then have checkboxes and drop down boxes that bind to fields within the BindingItem.
Everything works great until I refresh the entire appointments collection.
It seems like DataTemplates are being reused (by the container?) and any interaction seems to be with the old BindingItem not the new one, even though the appointment collection is brand new and each appointment has a new BindingItem set.
I can get this resolved in 2 ways, the first is to scroll the offending appointments off the screen and back again which must be forcing some kind of container refresh. Not very useful for end users.
The second is to use the following code to force a container refresh, note that AddIdleAction adds the code onto the dispatcher at application idle priority:
private void RefreshAppointmentBindingItem(CustomAppointment appt)
{
if (appt != null)
{
object item = appt.BindingItem;
AddIdleAction(() =>
{
appt.BindingItem = null;
});
AddIdleAction(() =>
{
appt.BindingItem = item;
});
}
}
Both ways are messy, do you have any better suggestions?
Thanks
Anthony