WatermarkedTextBox for Silverlight 2 Beta 2


One breaking change you may have noticed between Silverlight 2 Beta 1 and Beta 2 is that WatermarkedTextBox is no longer available in the Silverlight SDK (System.Windows.Controls.Extended.dll). 


We decided to remove the control because in a future version of Silverlight, we will be adding a “Watermark” property to TextBox. Given this upcoming change, it does not make sense to have “WatermarkedTextBox” as a separate control, so we decided to remove the control from Silverlight 2.


Because the update to TextBox will not happen until a future version of Silverlight feel free download and use the WatermarkedTextBox source code and unit test in the mean time. By downloading the source and unit tests you accept the license.


Here is an example on how to use it:


image


 

image

For more information on how to use this control, check out our Beta1 documentation in MSDN:


http://msdn.microsoft.com/en-us/library/system.windows.controls.watermarkedtextbox(VS.95).aspx


In additional to porting the source code & unit test for Beta 1, we also did the following:



  • Updated the template to use new features in the framework (i.e. VisualStateManager)

  • Bug fixing: When the control has focus, MouseOver state will no longer be active after moving the mouse away from the cotnrol

  • Bug fixing: Allow setting BorderBrush correctly

If you run into any problems, let me know! 🙂


<Editorial Note>
This is also a great example on how to use the new Visual State Manager for Silverlight 2 Beta 2!
Also a special “Thank you” to the WatermarkedTextBox dev Alex Bulankou for porting the source code, updating & fixing the bugs.
</Editorial Note>

Comments (32)

  1. One breaking change you may have noticed between Silverlight 2 Beta 1 and Beta 2 is that WatermarkedTextBox

  2. Just a quick note that one of the breaking changes from beta 2 was that the WatermarkedTextBox control

  3. With Silverlight 2 Beta 2 coming out there were a number of changes that will break applications written

  4. Programming says:

    One breaking change you may have noticed between Silverlight 2 Beta 1 and Beta 2 is that WatermarkedTextBox

  5. BenHayat says:

    Kathy, one quick question: When you say "Future version of SL" do you mean like SL 3 or are we still talking version 2?

    Thanks!

    ..Ben

  6. KathyKam says:

    Hi Ben,

    "future" means some future version after SL 2.

    Thanks,

    Kathy

  7. KierenH says:

    Hope watermark is available on similar controls like ComboBox – this could be exposed via control template or attached property like ToolTip.

  8. Silverlight 2.0: La desaparecida WatermarkedTextBox

  9. Hi Kathy,

    I previously upgraded the control for Silverlight 2 beta 2 as well (http://craign.net/2008/06/10/watermarkedtextbox-control-for-silverlight-2-beta-2/) however I never took advantage of the VSM.

    Are you going to update the control to use the DefaultStyle and generic.xaml so that it can be styled using a future build of Blend? I was about to blog the updated code when I saw your post on it. Would you like a copy of my changes perhaps?

  10. Dans la Beta 1 de Silverlight 2 , on disposait d’un contrôle bien sympathique nommé WatermarkTextBox.

  11. Emil Stoychev with a Silverlight Twitter Widget, Kathy Kam on the missing WatermarkedTextBox, Adam Kinney

  12. Atul Gupta says:

    Kathy, Thanks for providing the same, but i guess we will have to either copy the source code into our projects, or rename the assembly, as it otherwise conflicts with the released System.Windows.Controls.Extended assembly which I would use to work with controls inside of it.

  13. Silverlight WatermarkedTextBox control code

  14. 작년 12월에 Silverlight 1.0 애플리케이션 맛보기 개발에 대한 글을 쓴 적이 있다. 어제 새벽 2시 정도에 잠을 깨는 바람에 Silverlight 2 애플리케이션 개발을 위한 튜터리얼을 보면서 실제로 개발하는 과정을 체험해보았다. Silverlight 1.0은 Javascript 만을 지원했고, GUI 애플리케이션 개발을 위한 라이브러리에 기본적으로 포함되어있는 레이아웃이나 컨트롤(위젯)들을 포함하고 있지 않았기 때문에, 이렇다 할

  15. shan says:

    How can I System.Windows.Controls in silverlight 2 beta 2.

  16. d_jedi says:

    How does this work now?

    Source code sln file opens with errors.

    I’m trying to follow Scott Guthrie’s silverlight tutorial.. but I can’t do it with this.

    AARGH.

  17. Mc David says:

    Why you don’t built a watermarkedtextbox .dll file cause when I download the zip file above I can’t build it, they said it’s not my currently using version!

  18. Nagapito says:

    The System.Windows.Controls.Extended.Test project misses a reference to the System.Windows.Controls.Extended project.

    After adding the reference, the solution builds!

  19. zazi says:

    I’ve just tested my compiled WatermarkedTextBox project with the Silverlight 2.0 RTW assemblies. When I built my Silverlight project with a WatermarkedTextBox inside I get the error:

    unknown attribute "Duration" for element "VisualTransition". [Line: 1 Position: 997]

    How I can solve this problem?

    Cheers zazi

  20. Joshua says:

    Hi~

    I tried using that.

    But it isn’t working.

    Could you explain to use that control in Silverlight 2 RTW(2.0.31005.0)?

    I want to use that control.

    Please~

  21. zazi says:

    For all who tried to get the WatermarkedTextBox assembly to work with Silverlight 2.0 RTW:

    You have to change the "Duration" property of the VisualTransition class in the WatermarkedTextBox.xaml of the project to "GeneratedDuration" – then it will work.

    Cheers Zazi

  22. Silverlight.net updated code samples

  23. Tim Heuer says:

    With the release of Silverlight 2 many people faced the task of ensuring their applications/code written

  24. Sheryl says:

    This article offers buggy code with inadequate information about how to use it. Very frustrating. WHERE does the compiled DLL go?? Why doesn’t the test code work? Someone commented that a reference is missing, but didn’t give the line of code that could fix it.

    Why bother posting something this sloppy – doesn’t help anyone.

  25. Sheryl says:

    There are tons of problems with this code. Even after I correct the problems that users kindly posted in comments, it does not run. The Test project snags on two Assert statements.

    You also give no information here on how to reference the controls built here. It’s a really inadequate article with buggy code.

    You chose not to post my previous comment. Fine – you don’t like criticism. But then at least fix the problem. Post instructions on how to fix the bugs, or post updated code, and add information on references the dlls in a new project. A newbie is not going to know this.

    Thank you for not censoring.

  26. KathyKam says:

    Hi Sheryl,

    Sorry that you were frustrated. But this code is for Silverlight 2 Beta 2. Are you trying to compile this with Silverlight 2 RTW? If so, then I am not surprised you ran into problems. There was quite a few breaking changes between Beta 2 and RTW.

    Tim has posted the updated code for WatermarkedTextBox for RTW that you might find helpful:

    http://timheuer.com/blog/archive/2008/10/22/silverlight-watermark-text-box-control.aspx

    RE: You choose not to post my previous comment
    I post all comments that are not spam, but I don’t check comments everyday. Particularly not on Saturday and Sundays. 🙂

    Thanks,

    Kathy

  27. Harshad says:

    Hi Kathy,

    I’m currently having Silverlight 3 beta version isntalled for development. I dont find any property as WaterMark for a textbox.

    – Harshad

  28. Fernando! says:

    Hello Kathy, thanks for help us! 😉 But i have a problem becouse i am learning to use silverlight and i don’t know what to do with the watermarkedtextbox.zip. Where does it go? In which directory i have to install it?

    Thank you very much for your help!!

  29. Keith says:

    Just playing with SL3 Beta, but still can’t find the Watermark property. Am i missing something?

  30. Justin says:

    The above watermark assembly doesn’t work anymore. Do a search in the System.Windows.Controls.Extended project for "VisualTransition". You’ll get 4 results, change the "Duration" attribute on each to "GeneratedDuration".

  31. annonymous says:

    yes Alter the 4 Duration to GeneratedDuration and build the System.Windows.Controls.Extended project and on your project you can have the watermarked work fine.