This is a migrated thread and some comments may be shown as answers.

Is there a way to disable the dropdown calendar in DateTimePicker

5 Answers 615 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Harlan
Top achievements
Rank 1
Harlan asked on 16 Nov 2012, 12:27 AM
Hi,
Does anyone know if there is a way to disable the dropdown calendar of the DateTimePicker?
I would still like to be able to enter the date in the text area.

Thanks

5 Answers, 1 is accepted

Sort by
0
Alek
Telerik team
answered on 16 Nov 2012, 02:10 PM
Hello Harlan,

There is no "out of the box" solution for your request. In order to set the described behavior you should change the control template to disable or hide the button. We've attached a sample project, where you can see how we've achieved this, but in short we followed these steps:

  • create a new folder in you solution and copy the references from NoXaml folder (installation directory). Entering in the Telerik.Windows.Controls.Input.xaml you should look how a comment "NOTE". There we made the change;
  • add a reference in App.xaml;

You can visit our online help page, where the whole process is described in a very detailed way.

Kind regards, Alek
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kim
Top achievements
Rank 1
answered on 17 Jun 2014, 02:21 AM
Hello Alek,
i just want it's made optional one time show one time not show.
so, i think make a behavior that below as..but it's not work.
please give your advice..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Telerik.Windows.Controls;namespace Lge.Bms.Viewer.CommonUI.Behavior
{
    /// <summary>
    /// Rad Control의 RadDropDownButton을 Visibility을 컨트롤 한다.
    /// </summary>
    public class RadControlDropDownButtonBehavior 
    {
        public static readonly DependencyProperty IsVisibilityProperty = DependencyProperty.RegisterAttached("IsVisibility", typeof(bool), typeof(RadControlDropDownButtonBehavior), new PropertyMetadata(true, OnControlActive));        public static void SetIsVisibility(DependencyObject d, bool enabled)
        {
            d.SetValue(IsVisibilityProperty, enabled);
        }        public static bool GetIsVisibility(DependencyObject d)
        {
            return (bool)d.GetValue(IsVisibilityProperty);
        }        private static void OnControlActive(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //추후 숨겨할 RadDropDownButton의 Name을 조건문에 추가 수정한다.
            switch (d.GetType().ToString())
            {
                case "Telerik.Windows.Controls.RadDateTimePicker":
                    var dropDownButtons = (d as RadDateTimePicker).ChildrenOfType<RadDropDownButton>().Where(x => x.Name == "PART_DropDownButton");
                    foreach (var item in dropDownButtons)
                    {
                        item.Visibility = (bool)e.NewValue ? Visibility.Visible : Visibility.Collapsed;
                    }
                    break;
                case "Telerik.Windows.Controls.RadTimePicker":
                    dropDownButtons = (d as RadTimePicker).ChildrenOfType<RadDropDownButton>().Where(x => x.Name == "PART_DropDownButton");
                    foreach (var item in dropDownButtons)
                    {
                        item.Visibility = (bool)e.NewValue ? Visibility.Visible : Visibility.Collapsed;
                    }
                    break;
            }
        }
    }
}
0
Alek
Telerik team
answered on 17 Jun 2014, 10:55 AM
Hi Kim,

Basically your code is working fine. The only change we've made is to moved the switch logic in the Loaded event as the control template needs a time to be loaded. This is the reason why it is not worked initially. 

For your convenience we've added a sample project as an attached file where you can see our approach. 
We hope that the solution will fit to your needs.

Regards,
Alek
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Kim
Top achievements
Rank 1
answered on 18 Jun 2014, 02:24 AM
Hi Alek,
thanks your solution,
it's problem that event ocurred loaded time.
0
Alek
Telerik team
answered on 23 Jun 2014, 08:45 AM
Hi Kim,

Could you please tell us is the proposed solution worked for you or you are still experiencing issues?

Regards,
Alek
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
DateTimePicker
Asked by
Harlan
Top achievements
Rank 1
Answers by
Alek
Telerik team
Kim
Top achievements
Rank 1
Share this question
or