The objective in unable the user to type a text and allow him to choose a date only by clicking button.
3 Answers, 1 is accepted
Can you please elaborate a bit more on your scenario? What do you mean by saying that you want the user to be able to select a date only by clicking a button? Is this some external button - defined separatly (for example RadButton)? Or do you mean the calendar buttons (the days in the calendar)?
If you want to restrict only the text entering in the input field, you can get the RadWatermarkTextBox from the RadDatePicker's visual tree, using the visual tree helper methods. And then set its IsEnabled property to False. Here is an example in code:
If you want to disable the calendar part you can set the IsEnabled property of the RadCalendar control via the CalendarStyle property of the RadDatePicker control.
My scenario is that I have a RadDatePicker inside a RadGridView. I want all my RadDatePickers to allow user to choose a date only from the calendar by clicking the button which pops up the calendar. As you mentioned I want to restrict only the text entering in the input field.
I hope my snippet code is sufficient to clarify my issue.
*Also*, I would like to present the date as "MM/yyyy" which I haven't managed to do yet, if you could help with it as well I would appreciate it.
Thanks in advance.
I've prepared a small sample project based on the code you provided to demonstrate how you can achieve the desired result by handling the PreparingCellForEdit event of the RadGridView control.
Inside the handler you can set a custom format for the date as well as cancel any user input by handling the RadDatePicker's PreviewTextInput event.
Please have a look at the attached project and let me know if it provides the desired result or if I've misunderstood your requirement in any way. I look forward to your reply.