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

Set DateTimeWatermarkContent from Style

5 Answers 313 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Gergely
Top achievements
Rank 1
Gergely asked on 16 Oct 2010, 10:07 AM
Hi

I wanted to set the default DateTimeWatermarkContent for RadDatePicker from Style. At first it seemed not working (the default "Enter date" text appeared), later I have defined the property for each RadDatePicker manually and later removed these manual overrides for some reason. Surprisingly, the Style definition seemed to work now, but only in Visual Studio (I could even change the default value and the designer followed the changes). However, when I have run the application, my style definition was not used ("Enter date", again). Even stranger that from this point on, the designer "forgot" to use the style again as well.

What am I doing wrong? It is possible to set this property from Style?

My code:

 <Window.Resources>
        <ResourceDictionary>
            <Style TargetType="telerik:RadDatePicker">
                <Setter Property="Culture" Value="hu-HU" />
                <Setter Property="MinWidth" Value="100" />
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="DateTimeWatermarkContent" Value=""/>
            </Style>
        </ResourceDictionary>
    </Window.Resources>
...
<telerik:RadDatePicker Grid.Column="1" Grid.Row="0"></telerik:RadDatePicker>
<telerik:RadDatePicker  Grid.Column="1" Grid.Row="2"></telerik:RadDatePicker>
...

Any ideas?

Thanks for the help in advance!


5 Answers, 1 is accepted

Sort by
0
Gergely
Top achievements
Rank 1
answered on 16 Oct 2010, 10:45 AM
I am sorry, I should have written my question in DatePicker not in DateTimePicker thread. Anyway, I have found out that styleing the mentioned property seems to work if I use a DateTimePicker. 
0
Dani
Telerik team
answered on 18 Oct 2010, 06:20 AM
Hello Gergely,

Thank you for sharing the issue you are experiencing. This behavior is a known issue which has been reported as a bug. You can vote for it in our PITS list here.

Meanwhile, you can use the following syntax to set the DateTimeWatermarkContent property:

<Setter Property="DateTimeWatermarkTemplate"
     <Setter.Value
         <DataTemplate
             <TextBlock Text="My custom watermark" Opacity="0.5" /> 
         </DataTemplate
     </Setter.Value
 </Setter>

Please, contact us again should you have any further inquiries.


Greetings,
Dani
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 19 Oct 2010, 12:40 PM
<Setter Property="DateTimeWatermarkTemplate"
     <Setter.Value
         <DataTemplate
             <TextBlock Text="My custom watermark" Opacity="0.5" /> 
         </DataTemplate
     </Setter.Value
 </Setter>

Work with Enabled control, but if it's disabled "Enter date" the notice is displayed
0
Dani
Telerik team
answered on 20 Oct 2010, 08:09 AM
Hi Alexander,

I tested the case and the watermark content is behaving as expected in WPF even with the control disabled. However, since this was not the case with the Silverlight control, you can also try  setting both the DateTimeWatermarkTemplate as already mentioned, and the DateTimeWatermarkContent property in the same style.

I think this will do the job for you. Please, let me know if you need further assistance.


Greetings,
Dani
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gergely
Top achievements
Rank 1
answered on 20 Oct 2010, 04:50 PM
Thank you for the answer, the provided solution works fine!
Tags
DateTimePicker
Asked by
Gergely
Top achievements
Rank 1
Answers by
Gergely
Top achievements
Rank 1
Dani
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or