Add Clear Button to WatermarkTextBox
Environment
Product Version | 2022.3.912 |
Product | RadWatermarkTextBox for WPF |
Description
How to add a clear button to the RadWatermarkTextBox control.
Solution
You can add a button as the AdditionalContent
of the RadWatermarkTextBox control and bind its Command
property to the RadWatermarkTextBoxCommands.Clear
command.
Add clear button as AdditionalContent
<telerik:RadWatermarkTextBox.AdditionalContent>
<telerik:RadButton Focusable="False" IsBackgroundVisible="False"
Command="telerik:RadWatermarkTextBoxCommands.Clear"
CommandTarget="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadWatermarkTextBox}}"
Visibility="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadWatermarkTextBox}, Path=Text, Converter={StaticResource NullToVisibilityConverter}}">
<telerik:RadGlyph Glyph="{StaticResource GlyphClose}"/>
</telerik:RadButton>
</telerik:RadWatermarkTextBox.AdditionalContent>