Is there a way to disable the dropdown calendar in DateTimePicker

6 posts, 0 answers
  1. Harlan
    Harlan avatar
    3 posts
    Member since:
    Nov 2012

    Posted 15 Nov 2012 Link to this post

    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

  2. Alek
    Admin
    Alek avatar
    78 posts

    Posted 16 Nov 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kim
    Kim avatar
    6 posts
    Member since:
    Nov 2013

    Posted 16 Jun 2014 in reply to Alek Link to this post

    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;
                }
            }
        }
    }
  5. Alek
    Admin
    Alek avatar
    78 posts

    Posted 17 Jun 2014 Link to this post

    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.
     
  6. Kim
    Kim avatar
    6 posts
    Member since:
    Nov 2013

    Posted 17 Jun 2014 in reply to Alek Link to this post

    Hi Alek,
    thanks your solution,
    it's problem that event ocurred loaded time.
  7. Alek
    Admin
    Alek avatar
    78 posts

    Posted 23 Jun 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready