Xceed Toolkit Plus for WPF v4.6 Documentation
WatermarkTextBox Class
Members  Example 


Xceed.Wpf.Toolkit Assembly > Xceed.Wpf.Toolkit Namespace : WatermarkTextBox Class
Represents a textbox control that permits the use of a watermark.
Syntax
'Declaration
 
<LocalizabilityAttribute(LocalizationCategory.Text)>
<ContentPropertyAttribute("Text")>
<TemplatePartAttribute(Name="PART_ContentHost", Type=System.Windows.FrameworkElement)>
<StyleTypedPropertyAttribute(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)>
<XmlLangPropertyAttribute("Language")>
<UsableDuringInitializationAttribute(True)>
<RuntimeNamePropertyAttribute("Name")>
<UidPropertyAttribute("Uid")>
<TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
<NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
Public Class WatermarkTextBox 
   Inherits AutoSelectTextBox
'Usage
 
Dim instance As WatermarkTextBox
[Localizability(LocalizationCategory.Text)]
[ContentProperty("Text")]
[TemplatePart(Name="PART_ContentHost", Type=System.Windows.FrameworkElement)]
[StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]
[XmlLangProperty("Language")]
[UsableDuringInitialization(true)]
[RuntimeNameProperty("Name")]
[UidProperty("Uid")]
[TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
[NameScopeProperty("NameScope", System.Windows.NameScope)]
public class WatermarkTextBox : AutoSelectTextBox 
Example
The following example shows how to create a simple WatermarkTextBox
<xctk:WatermarkTextBox Watermark="Enter First Name" />
The following example shows how to create a WatermarkTextBox that displays text and an image.
<xctk:WatermarkTextBox>
    <xctk:WatermarkTextBox.Watermark>
        <StackPanel Orientation="Horizontal">
            <Image Source="Contact16.png" Stretch="None" />
            <TextBlock Text="Enter First Name" Margin="4,0,0,0" />
        </StackPanel>
    </xctk:WatermarkTextBox.Watermark>
</xctk:WatermarkTextBox>
The following example shows how to create a WatermarkTextBox that uses a custom WatermarkTemplate.
<xctk:WatermarkTextBox Watermark="Enter First Name">
    <xctk:WatermarkTextBox.WatermarkTemplate>
        <DataTemplate>
            <Border BorderBrush="Green" BorderThickness="1">
                <ContentControl Content="{Binding}" Foreground="DarkRed" FontWeight="Bold" Focusable="False" />
            </Border>
        </DataTemplate>
    </xctk:WatermarkTextBox.WatermarkTemplate>
</xctk:WatermarkTextBox>
Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Media.Visual
            System.Windows.UIElement
               System.Windows.FrameworkElement
                  System.Windows.Controls.Control
                     System.Windows.Controls.Primitives.TextBoxBase
                        System.Windows.Controls.TextBox
                           Xceed.Wpf.Toolkit.AutoSelectTextBox
                              Xceed.Wpf.Toolkit.WatermarkTextBox
                                 Xceed.Wpf.Controls.SearchTextBox
                                 Xceed.Wpf.Toolkit.PropertyGrid.Editors.PropertyGridEditorTextBox
                                 Xceed.Wpf.Toolkit.WatermarkPasswordBox

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

WatermarkTextBox Members
Xceed.Wpf.Toolkit Namespace