WatermarkedTextBox control for Silverlight 2 beta 2
June 10, 2008 – 10:17 pm
When Microsoft released Silverlight 2 beta 1 they included a really cool control called the System.Windows.Controls.WatermarkedTextBox control. It lived in the assembly System.Windows.Controls.Extended.dll and was included in your XAP file when you did a build. However in Silverlight 2 beta 2 the one control that didn’t make it was the WatermarkedTextBox control.
So by popular request, I have upgraded the original source code which Microsoft published under the Microsoft Public License, I have repackaged the control to ease the migration of existing beta 1 applications. In order to avoid any confusion I’ve changed the namespace of the control. This should hopefully prevent any issues when or if Microsoft decide to release their own version again.
To use the replacement control, simply build the provided solution and add a reference from your existing project to the assembly CraigN.Windows.Controls.dll and use the namespace CraigN.Windows.Controls. So typically this will involve adding xmlns:CraigN_Windows_Controls="CraigN.Windows.Controls;assembly=CraigN.Windows.Controls" to the UserControl element of your XAML file.
Then simply prefix all WatermarkedTextBox elements in the XAML file with CraigN_Windows_Controls: and all code should build again.
You can download the source code from here. I have taken the time to ensure that original test cases build. If you have any comments or suggestions, I’d like to hear them.

11 Responses to “WatermarkedTextBox control for Silverlight 2 beta 2”
Hey Craig
Thanks for this code. It should be helpful.
By David Jankelowitz on Jun 17, 2008
Hi Craig
I added the reference to my app. But I get a type not found error. Have I implemented it correctly below?
Todo: Stories will display here….
By David Jankelowitz on Jun 17, 2008
I’ve actually detected a bug in the code I’ve posted. I’ll update it soon.
By Craig Nicholson on Jun 17, 2008
did this ever get figured out? i get type not found as well..
By loch on Jun 21, 2008
The “type not found error” is caused by a slight error in the assembly reference shown above. I believe it should read:
xmlns:CraigN_Windows_Controls=”clr-namespace:CraigN.Windows.Controls;assembly=CraigN.Windows.Controls”
By Tim Bell on Jun 24, 2008
Kathy Kam has released an updated control over here http://blogs.msdn.com/kathykam/archive/2008/06/23/watermarkedtextbox-for-silverlight-2-beta-2.aspx.
By Craig Nicholson on Jun 25, 2008
I can see it in the Object Browser, I have made a reference to it, but I get a ” The type ‘CraigN_Windows_Controls:WatermarkedTextBox’ was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built” error when using it in the .xaml file
By Rui on Jul 14, 2008
I have put the control but when i am runnig the application i m not able to insert text in textbox.
What should be the problem ?
By shan on Aug 8, 2008
I am using solution instead of Kathy’s as it does not overwrite the System.Windows.Control.Extended dll that ships with 2.0 but I am running into a problem. Here is what I did.
- I was able to sucessful build the project after removing the strong name verification and installing it in the gac.
- Using the second tutorial from Scott’s blog, I was able to include a WatermarkedTextbox using your namespace, but now I get a compile time error saying “Length cannot be less than 0. Parameter name:length”
Can you please help me figure out what is causing this problem? Thanks
By Afshan on Sep 18, 2008