DatePickerTextBox.Watermark Property


Gets or sets the content displayed as a watermark in the DatePickerTextBox when it is empty.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows.Controls (in System.Windows.Controls.dll)

public Object Watermark { get; set; }
<controlsPrimitives:DatePickerTextBox Watermark="uistring"/>

XAML Values


A single UIElement (such as Path or Image) that displays the intended watermark content.


A string that provides the watermark content.

Property Value

Type: System.Object
The content displayed as a watermark in the DatePickerTextBox when it is empty.

The Watermark property detects whether the DatePicker format is set to Long or Short and provides the correct long or short format hint to the user.

The following examples show how to change the watermark value displayed in a DatePicker control by deriving from DatePicker, retrieving the textbox part and setting its Watermark property. This change only affects the empty DatePicker, before a date is selected. Once a date is selected the date is then removed, the DatePicker reverts to the default behavior of either a long or short format hint.

Run this sample

// Create a class that inherits from DatePicker.
public class MyDatePicker : DatePicker
  // Override OnApplyTemplate to retrieve the DatePickerTextBox part of the template.
    public override void OnApplyTemplate()
        DatePickerTextBox box = base.GetTemplateChild("TextBox") as DatePickerTextBox;

        string formatString = "";
        if (this.SelectedDateFormat == DatePickerFormat.Short)
            formatString = "mm/d/yy";
        if (this.SelectedDateFormat == DatePickerFormat.Long)
            formatString = "dddd, MMMM, dd, yyyy";

        // Set the Watermark property.
        box.Watermark = "Type ( " + formatString + " or select a date --> ";

The following XAML shows how to use the derived DatePicker in a page.

    <UserControl x:Class="DatePickerWatermarkVB.MainPage"
    xmlns:local ="clr-namespace:DatePickerWatermarkVB"
    d:DesignHeight="300" d:DesignWidth="400" 
    <Grid x:Name="LayoutRoot" Background="White">
        <local:MyDatePicker Width="240" Height="30" />


Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions