【问题标题】:How to auto-close a telerik RadDateTimePicker on selected date如何在选定日期自动关闭 Telerik RadDateTimePicker
【发布时间】:2015-07-08 11:49:44
【问题描述】:

控件声明如下:

 <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 年前,目前的答案都没有解决我的问题。

【问题讨论】:

    标签: wpf telerik telerik-datepicker


    【解决方案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;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 2012-05-29
      • 2016-03-13
      相关资源
      最近更新 更多