# Features

The `RadWatermarkTextBox` control supports watermark content, focus selection, and additional content. Its main properties are:

* `WatermarkContent`—Gets or sets the watermark content. By default, it appears when the text box is empty and not focused. See [WatermarkBehavior](https://www.telerik.com/products/wpf/documentation/controls/radwatermarktextbox/features#watermarkbehavior) for other visibility modes.

* `WatermarkTemplate`—Gets or sets the template for the watermark content. Its visibility follows the same [WatermarkBehavior](https://www.telerik.com/products/wpf/documentation/controls/radwatermarktextbox/features#watermarkbehavior) setting as `WatermarkContent`.

* `CurrentText`—Gets or sets the text of the text box. Use this property with `TwoWay` binding to update the binding source on each text change rather than when the control loses focus.

* `IsWatermarkVisible`—A read-only property that indicates whether the watermark is visible.

* `SelectionOnFocus`—Specifies how the selection changes when the control receives focus. The `SelectionOnFocus` enumeration provides these values:

  * `Unchanged`—Leaves the selection unchanged.

  * `SelectAll`—Selects all text.

  * `CaretToBeginning`—Moves the caret to the start of the text.

  * `CaretToEnd`—Moves the caret to the end of the text.

* `AdditionalContent`—Gets or sets an object rendered in a `ContentPresenter` on the right side of the control.

* `AdditionalContentTemplate`—Gets or sets the `System.Windows.DataTemplate` used for the `AdditionalContent` object.

> tip The `RadWatermarkTextBox` control is part of the `Telerik.Windows.Controls.dll` assembly.

For project setup and theme configuration, follow the [RadWatermarkTextBox getting-started guide](https://www.telerik.com/products/wpf/documentation/controls/radwatermarktextbox/getting-started).

## Using the WatermarkContent Property

Use the `WatermarkContent` property to define a prompt for an empty text box.

The following example displays a prompt asking for four digits, not a validation rule:

**Setting the `WatermarkContent` property**

```XAML
<telerik:RadWatermarkTextBox x:Name="radWatermarkTextBox" WatermarkContent="Please Enter Four Digits:" />
```

> caption `RadWatermarkTextBox` with watermark text

![WPF RadWatermarkTextBox with Watermark Text](https://www.telerik.com/products/wpf/documentation/assets/beec23cba542f1fb105a7c5d5fb6eb14/radwatermarktextbox_overview_010.png)

The `WatermarkContent` property is of type `object`, which means that you can set a value of any type. For example:

**Defining custom content for the `WatermarkContent` property**

```XAML
<telerik:RadWatermarkTextBox x:Name="radWatermarkTextBox1">
    <telerik:RadWatermarkTextBox.WatermarkContent>
        <StackPanel Orientation="Horizontal">
            <Image Source="/Silverlight.Help.RadMaskedTextBox;component/Images/EURFlag.png" />
            <TextBlock Margin="3,0,0,0" Text="Please Enter Four Digits" />
        </StackPanel>
    </telerik:RadWatermarkTextBox.WatermarkContent>
</telerik:RadWatermarkTextBox>
```

> caption `RadWatermarkTextBox` with custom watermark content

![WPF RadWatermarkTextBox with Custom Watermark Content](https://www.telerik.com/products/wpf/documentation/assets/541731607a68467c29088a979f5061e9/radwatermarktextbox_overview_020.png)

## Using WatermarkTemplate Property

Use the `WatermarkTemplate` property to define a `DataTemplate` for the watermark content.

**Defining the `WatermarkTemplate`**

```XAML
<telerik:RadWatermarkTextBox x:Name="radWatermarkTextBox2">
    <telerik:RadWatermarkTextBox.WatermarkTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <Image Source="/Silverlight.Help.RadMaskedTextBox;component/Images/EURFlag.png" />
                <TextBlock Margin="3,0,0,0" Text="Please Enter Four Digits" />
            </StackPanel>
        </DataTemplate>
    </telerik:RadWatermarkTextBox.WatermarkTemplate>
</telerik:RadWatermarkTextBox>
```

> caption `RadWatermarkTextBox` with custom `WatermarkTemplate`

![WPF RadWatermarkTextBox Custom WatermarkTemplate](https://www.telerik.com/products/wpf/documentation/assets/541731607a68467c29088a979f5061e9/radwatermarktextbox_overview_030.png)

## Setting the SelectionOnFocus Property

The `SelectionOnFocus` property of `RadWatermarkTextBox` controls the text selection and caret position when the control receives focus. The following example sets `SelectionOnFocus` to `SelectAll` to select all text on focus.

**Setting the `SelectionOnFocus` property**

```XAML
<telerik:RadWatermarkTextBox x:Name="radWatermarkTextBox3" 
	                             SelectionOnFocus="SelectAll"
	                             WatermarkContent="Please Enter Four Digits:" />
```

## WatermarkBehavior

The `WatermarkBehavior` property of `RadWatermarkTextBox` specifies when to hide the watermark content. It accepts these values:

* `HiddenWhenFocused`—Hides the watermark when the control receives focus.
* `HideOnClick`—Hides the watermark when the user clicks the control.
* `HideOnTextEntered`—Hides the watermark when the user enters text into the control.

The default value is `HiddenWhenFocused`.

## ReadOnlyBackground and DisabledBackground

The `RadWatermarkTextBox` control exposes `DisabledBackground` and `ReadOnlyBackground` to set its background in the disabled and read-only states, respectively.

**Setting the `DisabledBackground` property**

```XAML
<telerik:RadWatermarkTextBox WatermarkContent="Please Enter Four Digits:" IsEnabled="False" DisabledBackground="DarkGray" />
```

> caption Disabled `RadWatermarkTextBox` with and without `DisabledBackground`

![WPF RadWatermarkTextBox with and without Disabled Background](https://www.telerik.com/products/wpf/documentation/assets/7d57021e2cdc1d307c3ed213b8b34535/disabledbackground.png)

**Setting the `ReadOnlyBackground` property**

```XAML
<telerik:RadWatermarkTextBox WatermarkContent="Please Enter Four Digits:" IsReadOnly="True" ReadOnlyBackground="DarkGray" />
```

> caption Read-only `RadWatermarkTextBox` with and without `ReadOnlyBackground`

![WPF RadWatermarkTextBox with and Without Read Only Background](https://www.telerik.com/products/wpf/documentation/assets/3ef71a6a89c6a84dcae72903b2a48497/readonlybackground.png)

> note The read-only visual appears over the disabled visual. `ReadOnlyBackground` takes precedence over `DisabledBackground` when the control is both disabled and read-only.

## Clear Command

The `RadWatermarkTextBoxCommands` class exposes the `Clear` command, which clears the text of the text box.

**Using the `Clear` command**

```XAML
<StackPanel>
    <telerik:RadWatermarkTextBox x:Name="watermarkTextBox" />

    <telerik:RadButton Command="telerik:RadWatermarkTextBoxCommands.Clear"
           CommandTarget="{Binding ElementName=watermarkTextBox}">
        <telerik:RadGlyph Glyph="&#xe11b;"  />
    </telerik:RadButton>
</StackPanel>
```

## AdditionalContent and AdditionalContentTemplate

The `RadWatermarkTextBox` control exposes `AdditionalContent` and `AdditionalContentTemplate` to display and template additional content on its right side.

The following example demonstrates the `AdditionalContent` and `AdditionalContentTemplate` properties along with the `Clear` command.

**Setting the `AdditionalContent` and `AdditionalContentTemplate` properties**

```XAML
<Grid>
    <Grid.Resources>
        <DataTemplate x:Key="ClearWatermarkTextBoxAdditionalContentTemplate">
            <telerik:RadButton Focusable="False" 
	                       IsBackgroundVisible="False" 
	                       Command="telerik:RadWatermarkTextBoxCommands.Clear" 
	                       CommandTarget="{Binding ElementName=watermarkTextBox}">
                <telerik:RadGlyph Glyph="{Binding}"/>
            </telerik:RadButton>
        </DataTemplate>
    </Grid.Resources>
    <telerik:RadWatermarkTextBox Name="watermarkTextBox"
	                                 AdditionalContent="&#xe11b;"
	                                 AdditionalContentTemplate="{StaticResource ClearWatermarkTextBoxAdditionalContentTemplate}"/>
</Grid>
```

> caption `RadWatermarkTextBox` with custom `AdditionalContent` and `AdditionalContentTemplate` properties

![WPF RadWatermarkTextBox Custom AdditionalContent and AdditionalContentTemplate Properties](https://www.telerik.com/products/wpf/documentation/assets/0aec00b8074bf14e258c7d3b53367ce0/radwatermarktextbox-features-additionalcontent.png)

## See Also

* [RadWatermarkTextBox overview](https://www.telerik.com/products/wpf/documentation/controls/radwatermarktextbox/overview)
