I am trying to use two DatePicker controls to specify a start and end date within a specified range, whilst also limiting the selections so that the start date is before the end date and the end date is after the start date.
So I have tried this XAML:
<GroupBox Grid.Row="1" Header="Run Length">
<StackPanel Orientation="Horizontal">
<DockPanel VerticalAlignment="Top">
<Label DockPanel.Dock="Left">Start Date</Label>
<DatePicker DockPanel.Dock="Right" Height="25" SelectedDate="{Binding Path=RunStartDate, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" DisplayDateStart="{Binding Path=MinDate, Mode=OneWay, NotifyOnSourceUpdated=True}" DisplayDateEnd="{Binding Path=RunEndDate, Mode=OneWay, NotifyOnSourceUpdated=True}"></DatePicker>
</DockPanel>
<DockPanel VerticalAlignment="Top">
<Label DockPanel.Dock="Left">End Date</Label>
<DatePicker DockPanel.Dock="Right" Height="25" SelectedDate="{Binding Path=RunEndDate, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" DisplayDateStart="{Binding Path=RunStartDate, Mode=OneWay, NotifyOnSourceUpdated=True}" DisplayDateEnd="{Binding Path=MaxDate, Mode=OneWay, NotifyOnSourceUpdated=True}"></DatePicker>
</DockPanel>
</StackPanel>
</GroupBox>
However when the values of ‘MinDate’ and ‘MaxDate’ change, the DatePickers do not? Can anyone explain why?
Thanks,
Alex.
Make sure
MinDateandMaxDateare public properties which implementINotifyPropertyChanged.Here is a MSDN example to help you out.