WindowsPhoneWatermarkTextBox is really simple to use.

First, include the WindowsPhoneWatermarkTextBoxControl.dll to your project.

In your XAML page, add the my namespace for WindowsPhoneWatermarkTextBoxControl like in the example below:

<phone:PhoneApplicationPage 
    x:Class="WatermarkTextBoxExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    d:DataContext="{d:DesignData SampleData/ViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    shell:SystemTray.IsVisible="True" 
    xmlns:my="clr-namespace:System.Windows.Controls;assembly=WindowsPhoneWatermarkTextBoxControl">

   <!-- Your page -->

</phone:PhoneApplicationPage>

Then, you can had the control. The WatermarkText property is used to set the Watermark:

<my:WatermarkTextBox Name="watermarkTextBox" Width="456" Height="72" Margin="0,128,0,407" HorizontalAlignment="Left" WatermarkText="Enter a text..." />

You can easily access to both Text property and WatermarkText property:

this.watermarkTextBox.Text  // Get or set regular Text value
this.watermarkTextBox.WatermarkText  // Get ot set watermark

Voila!

Last edited Mar 26, 2011 at 4:08 PM by arclightpsx, version 2

Comments

BrookYI Aug 8, 2014 at 3:49 AM 
"IsReadOnly" and "IsEnable" doesn't work.
it will crash.

ChrisSippel Mar 28, 2014 at 8:40 PM 
Works like a charm! Does exactly what it is supposed to do!

VijayDhas_MCA Dec 20, 2013 at 8:42 AM 
Hi.. I have download this sample project. But when i try to execute It shows Some error.
The error is


Error 1 Unable to load the metadata for assembly 'WindowsPhoneWatermarkTextBoxControl'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'WindowsPhoneWatermarkTextBoxControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x8013151)

What is have to do. Please don't mistake me. I am new to windows phone application development.

Mech0z Jan 8, 2012 at 7:48 PM 
Any way to clear the text field and then get the watermark text shown again?