This question is locked. New answers and comments are not allowed.
Hi,
I'd like to make a DateTimePicker where the available time-of-day values depend on the day chosen.
I was thinking I could just bind the ClockItemsSource to an ObservableCollection, and then change the contents of the collection depending on the day chosen.
Here's my simplified XAML:
And the code-behind looks like this:
The problem is that the time-of-day values displayed never change - it is as if the time picker ignores the ObservableCollection change events!
Can anyone tell me what I'm doing wrong - or if there's a way to force the time picker to update itself?
We're approaching a deadline, and I'm really stuck here - any help would be greaty appreciated!
I'd like to make a DateTimePicker where the available time-of-day values depend on the day chosen.
I was thinking I could just bind the ClockItemsSource to an ObservableCollection, and then change the contents of the collection depending on the day chosen.
Here's my simplified XAML:
<UserControl ...> <NIBControls:VoyagePicker x:Name="DateTimePicker"/></UserControl>And the code-behind looks like this:
public partial class VoyagePicker : UserControl{ public VoyagePicker() { InitializeComponent(); DateTimepicker.ClockItemsSource = m_selectedDayVoyageTimes; m_selectedDayVoyageTimes.Add(new TimeSpan(10, 11, 12)); DateTimepicker.SelectionChanged += DateTimepicker_SelectionChanged; } private readonly ObservableCollection<TimeSpan> m_selectedDayVoyageTimes = new ObservableCollection<TimeSpan>(); void DateTimepicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.m_selectedDayVoyageTimes.Add(new TimeSpan(14, 15, 16)); }}}The problem is that the time-of-day values displayed never change - it is as if the time picker ignores the ObservableCollection change events!
Can anyone tell me what I'm doing wrong - or if there's a way to force the time picker to update itself?
We're approaching a deadline, and I'm really stuck here - any help would be greaty appreciated!