控件声明如下:
<telerik:RadDateTimePicker InputMode="DateTimePicker"
IsTabStop="False"
Height="36"
Focusable="False"
Validation.ErrorTemplate="{x:Null}"
SelectionOnFocus="SelectAll"
x:Name="OutwardStartDate"
BorderThickness="2,2,2,2"
SelectedValue="{Binding OutwardDepartureDate, Mode=TwoWay, ValidatesOnDataErrors=true,
NotifyOnValidationError=true}" >
我无法找到任何XAML属性,以便在选择日期时自动关闭此控件。我偶然发现了this post on the official website,但这个问题可以追溯到5年前,目前的答案都没有解决我的问题。
答案 0 :(得分:1)
您可以简单地挂钩 SelectionChanged 事件。
在您的XAML中如下:
<telerik:RadDateTimePicker InputMode="DateTimePicker"
SelectionChanged="RadDateTimePicker_SelectionChanged"
IsTabStop="False"
Height="36"
Focusable="False"
Validation.ErrorTemplate="{x:Null}"
SelectionOnFocus="SelectAll"
x:Name="OutwardStartDate"
BorderThickness="2,2,2,2"
SelectedValue="{Binding OutwardDepartureDate,
Mode=TwoWay,
ValidatesOnDataErrors=true,
NotifyOnValidationError=true}">
并在后面的代码中更改 IsDropDownOpen 属性:
private void RadDateTimePicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems != null)
{
var dateTimePicker = sender as RadDateTimePicker;
dateTimePicker.IsDropDownOpen = false;
}
}