Set DateTimeWatermarkContent from Style

6 posts, 0 answers
  1. Gergely
    Gergely avatar
    11 posts
    Member since:
    Oct 2010

    Posted 16 Oct 2010 Link to this post

    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!


  2. Gergely
    Gergely avatar
    11 posts
    Member since:
    Oct 2010

    Posted 16 Oct 2010 Link to this post

    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. 
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dani
    Admin
    Dani avatar
    848 posts

    Posted 18 Oct 2010 Link to this post

    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
  5. Alexander
    Alexander avatar
    1 posts
    Member since:
    Jul 2010

    Posted 19 Oct 2010 Link to this post

    <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
  6. Dani
    Admin
    Dani avatar
    848 posts

    Posted 20 Oct 2010 Link to this post

    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
  7. Gergely
    Gergely avatar
    11 posts
    Member since:
    Oct 2010

    Posted 20 Oct 2010 Link to this post

    Thank you for the answer, the provided solution works fine!
Back to Top
UI for WPF is Visual Studio 2017 Ready