Open RadDatePicker programmatically

8 posts, 2 answers
  1. Alex
    Alex avatar
    21 posts
    Member since:
    Apr 2012

    Posted 06 Aug 2012 Link to this post

    Hello.

    Is there a way to open RadDatePicker from the code? I want use it in such way:

    var datePicker = new RadDatePicker();
    this.LayoutRoot.Children.Add(datePicker);
    ...
    datePicker.Open();

    I've found an implementation for DatePicker from Silverlight Toolkit:
    http://transoceanic.blogspot.com/2011/08/wp7-create-datepicker-control.html
    But I can't adapt this example for RadDatePicker.

    Thanks in advance.

    P.S. I've made a mistake in the title of the post - "programmatically". Please fix it.
  2. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 07 Aug 2012 Link to this post

    Hi Alex,

    Yes, you can open RadDatePicker programmatically. You can do it by setting the IsPopupOpen property to true. This will cause the popup to expand and the user will be able to select a new date.

    All the best,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Alex
    Alex avatar
    21 posts
    Member since:
    Apr 2012

    Posted 07 Aug 2012 Link to this post

    Ok. Thanks. If I try to use this functionality from code then it works fine.

    And I've tried to implement this by using of binding. But with no success. Popup doesn't open.
    Can I change IsPopupOpen property through binding? 
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 08 Aug 2012 Link to this post

    Hi Alex,

    We are changing the value of the IsPopupOpen property programmatically and the new value that we set replaces your binding. The solution is to create two-way binding to the IsPopupOpen property. For example if you have ToggleButton, instead of binding IsPopupOpen to ToggleButton's IsChecked property, you should do the opposite:
    <telerikInput:RadDatePicker x:Name="datePicker" />
    <ToggleButton Content="open popup" IsChecked="{Binding ElementName=datePicker, Path=IsPopupOpen, Mode=TwoWay}"/>


    Kind regards,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Alex
    Alex avatar
    21 posts
    Member since:
    Apr 2012

    Posted 08 Aug 2012 Link to this post

    In my previous post I meant that I want to use RadDatePicker in a such way:


    <
    telerik:RadDatePicker 
    IsPopupOpen="{Binding IsPopupOpen, Mode=TwoWay"/>

    public class DataViewModel: INotifyPropertyChanged
    {
    //...
      private bool _isPopupOpen; 
     
      public bool IsPopupOpen
      {
        get
        {
          return _isPopupOpen;
        }
     
        set
        {
          _isPopupOpen = value;
          OnNotifyChanged("IsPopupOpen");
        }
      }
    //...
      private Method()
      {
        IsPopupOpen = true;
      }
    //...
    }

    I want to invoke Method() to open DatePicker.
    Will this code work or not?
  7. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 09 Aug 2012 Link to this post

    Hi Alex,

    This code will not have the desired effect, because in the current version of RadDatePicker we are changing the value of the IsPopupOpen property internally and this breaks the binding. We are going to change that so that you will be able to open the popup with the code that you are using. The changes will be included in our next internal build, which will be released next week. Stay tuned and get it from the Downloads section of your account, once it's available.

    Greetings,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Tomas
    Tomas avatar
    4 posts
    Member since:
    Nov 2014

    Posted 03 Feb 2015 in reply to Todor Link to this post

    Hello,

    I tried same thing today and i think that the binding still not work.

  9. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    551 posts

    Posted 06 Feb 2015 Link to this post

    Hello Tomas,

    Thank you for contacting us. It seems that the fix for this issue didn't make it to the official version for some reason. We will include it in the next release. Thank you very much for pointing out this issue. I have updated your Telerik points as a token of gratitude.  

    Regards,
    Rosy Topchiyska
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner