Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Changing WeekDisplayMode to WorkWeek then back to None does not work (2014.1)
posted

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

Parents
  • 34510
    Verified Answer
    Offline posted

    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();

Reply Children
  • 34510
    Offline posted in reply to DaveS

    Hello Dave,

    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.