Wpf DatePicker范围选择限制(转)
Wpf DatePicker范围选择限制
版权声明: https://blog.csdn.net/yedekuqi4712/article/details/80594606
需要实现:两个DatePicker,(1)第一个选择时间后,再选择第二个,不能在第一个时间之前;(2)第二个选择后,再选择第一个,不能在第二个时间之后。
代码:
-
<DatePicker Height="25"
-
HorizontalAlignment="Left"
-
Margin="163,36,0,0"
-
Name="datePicker1"
-
VerticalAlignment="Top"
-
Width="115"
-
DisplayDateEnd="{Binding SelectedDate,ElementName=datePicker2}"/>
-
<DatePicker Height="25"
-
HorizontalAlignment="Left"
-
Margin="324,34,0,0"
-
Name="datePicker2"
-
VerticalAlignment="Top"
-
Width="115"
-
DisplayDateStart = "{Binding SelectedDate,ElementName=datePicker1}"/>
结果: