Hello,
I have noticed some strange behavior: I have a XamDayView with the WeekDisplayMode data-bound to an enumeration on the ViewModel. The WeekDisplayMode is controlled from a ComboBox whose ItemsSource is a list of WeekDisplayMode's. Window loads, the default is None. User changes to WorkWeek, DayView renders fine (with 5 days). User changes back to None, and the DayView remains in WorkWeek view. I noticed that the VisibleDates read-only collection remains with 5 days, even though the mode is set to None. I have also noticed reading from the VisibleDates collection in code seems to make the DayView stick in WeekDisplayMode.None (before changing it via ComboBox).
Am I doing something wrong?
As indicated in the forum topic, I am using 14.1.20141.2108. Thanks
Hello Dave,
Here is the description for what None does:
"The dates displayed in the ScheduleTimeControlBase is based upon the dates in the ScheduleControlBase.VisibleDates and may be discontiguous."
So what is happening here is, when the WeekDisplayMode is changed to WorkWeek the VisibleDate collection is changed to reflect this. When going back to None though, it doesn't reset the visible dates so it just uses whatever is there. It works the first time you run because there is only one date in the VisibleDates collection.
Now, I'm not sure where you saw that VisibleDates is a read-only collection but VisibleDates is a DataCollection object which derives from ObservableCollection<T>, ICollection<T>, IEnumerable<T> and IEnumerable so you can definitely modify it. When the WeekDisplayMode property is set to None, you should clear the VisibleDates collection so it displays the single day it did before.
xamDayView1.VisibleDates.Clear();
Thanks for the feedback!
I tried clearing the Visible dates when selecting None and it worked nicely. Maybe setting the display mode to None should automatically clear the VisibleDates collection in a future release?
I might have been confusing VisibleDates being ReadOnly with it not having an accessible setter when trying to data bind the collection. I don't have any reason to data bind the collection in this instance, but is there a reason why it is not able to?
You can suggest this as a new product idea here. This lets you directly communicate with our product management team. If you do add this to the product idea website, be sure to include this forum thread so our product managers can look back to it.
For the ReadOnly stuff, I see what you mean now. When you said ReadOnly I made the assumption that you meant the collection was not modifiable(no Add() or Remove()) rather than it just didn't have a setter. Sorry about that. It is true that it does not have a setter and that is because the control does not want users to be able to create a new instance of the collection. I believe a OneWayToSource binding should allow the binding to work. Since the VisibleDates instance doesn't ever change it should be enough.
Got it. Thanks!