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

Can you hide the Textbox?

10 Answers 208 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 14 Mar 2013, 11:24 AM
Is there a simple way to hide the textbox portion of the RadDatePicker control? I want the button and calendar functionality to remain as is but want to completely override the display method.

Thanks.

10 Answers, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 19 Mar 2013, 08:50 AM
Hi Andrew,

There are two possible solutions in removing the input RadWatermarkTextBox of the DatePicker control.
  1. Edit the Template of the control and remove the corresponding RadWatermarkTextBox.
  2. Use the Loaded event of the control, drill to the RadWatermarkTextBox and set its Visibility to Collapsed.

The next code snippet shows how the Loaded event should look like in order to remove the input WatermarkTextBox:
in xaml:

<telerik:RadDatePicker Loaded="DatePicker_Loaded_1"/>

and in the code behind:
private void DatePicker_Loaded_1(object sender, RoutedEventArgs e)
{
    var datePicker = sender as RadDatePicker;
    var datePickerTextBox = datePicker.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault() as RadWatermarkTextBox;
    datePickerTextBox.Visibility = System.Windows.Visibility.Collapsed;
}

Hope this is helpful.

All the best,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 17 Nov 2016, 02:51 PM

Hello Vladi,

 

I'm working with telerik:RadDateTimePicker and I want to hide the Watermark input control, but with your code, datePickerTextBox is null. I changed the cast for sender  but the cast doesn't work. I searched differents controls like RadWatermarkTextBox but I didn't find it.

 

Can you help me ? Thank you.

0
Nasko
Telerik team
answered on 21 Nov 2016, 07:30 AM
Hi Valentin,

The "datePickerTextBox" is still null because the RadWatermarkTextBox placed inside the DateTimePicker is not loaded completely. In order to get it as desired using the ChildrenOfType<T> method you need to call it inside a Dispatcher:
private void RadDateTimePicker_Loaded(object sender, RoutedEventArgs e)
{
    var datePicker = sender as RadDateTimePicker;
    Dispatcher.BeginInvoke(new Action(() =>
    {
        var datePickerTextBox = datePicker.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault() as RadWatermarkTextBox;
        datePickerTextBox.Visibility = System.Windows.Visibility.Collapsed;
    }));
}

Hope this helps.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 21 Nov 2016, 08:06 AM

Hello Nasko,

 

Thank you for your answer, but I tried with Dispatcher and datePickerTextBox is null yet.

 

I don't understand why.

 

Thank you.

0
Nasko
Telerik team
answered on 21 Nov 2016, 08:52 AM
Hi Valentin,

Please, check the attached sample that demonstrates how the proposed in my previous response approach works on our side - the "datePickerTextBox" is found as expected.

I hope this will help you.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 21 Nov 2016, 09:12 AM

Ho god.... I'm not in the good Forum ........ I'm so so sorry !

I'm working for WPF, not Silverlight.....

Do you no if there is an equivalent post for WPF or if I need to create it ?

I'm sorry again..

0
Nasko
Telerik team
answered on 21 Nov 2016, 12:43 PM
Hi Valentin,

We have checked the approach for WPF as well and it seems everything is working as expected without even using a Disptacher - the "datePickerTextBox" is found as expected. Please, check the attached WPF project that demonstrates that.

It will be of great help if you modify the project in order to reproduce your scenario and demonstrate your issue and send it back to us - thus we could be to provide you with a prompt solution.

Hope this helps.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 21 Nov 2016, 01:11 PM

Nasko,

 

Thank you but it doesn't working too. My scenario is the same that your.

My .Xaml :

<telerik:RadDateTimePicker x:Name="dtpSelectJour" Margin="0,0,10,0" InputMode="DatePicker" DateSelectionMode="Day"
DateTimeWatermarkContent="Sélectionner un jour de visualisation" IsEnabled="{Binding Path=IsChecked, ElementName=rdbtnSelectDay}" Loaded="dtpSelectJour_Loaded"/>

It is in a StackPanel which is in a telerik:RadRibbonGroup which is in a telerik:RadRibbonTab which is in a telerik:RadRibbonView.

And the Loaded method :

private void dtpSelectJour_Loaded(object sender, RoutedEventArgs e)
{
    var datePicker = sender as RadDateTimePicker;
    var datePickerTextBox = datePicker.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault() as RadWatermarkTextBox;
    datePickerTextBox.Visibility = System.Windows.Visibility.Collapsed;
}

 

The datePickerTextBox is always and always null. And I can't find the WatermarkTextBox.

 

NOTA :

It's stranlgy because I tried in an other project (like your because your project is not compatible with my VS 2010) and it working find.

 

Thank you.

0
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 21 Nov 2016, 02:47 PM

Nasko, I have a good new !

 

I seen that my RadDateTimePicker is loaded 3 times ! I don't know why, but the 2 first times, datePickerTextBox is null, but not the third times, and so, the WatermarkTextBox is well collapsed.

I seen too that the third loading is fired when i'm choose the correspondant RadRibbonTab (where there is my RadDateTimePicker). And this is the moment where my datePickerTextBox is find, and collapsed.

 

So thank you very much for your help !

 

Regards,

Valentin.

0
Nasko
Telerik team
answered on 22 Nov 2016, 08:26 AM
Hello Valentin,

I am glad to here you were able to resolve your issue and now everything is working as expected for you. Basically the Loaded event gets invoked several times while the RibbonView is loading itself into the visual tree - because of that when the RibbonView is not completely loaded the RadDateTimePicker could not find the desired RadWatermarkTextBox.

If you have any additional questions or concerns please, let us know.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
DatePicker
Asked by
Andrew
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Valentin
Top achievements
Rank 1
Iron
Iron
Nasko
Telerik team
Share this question
or