![]() |
Platforms, Frameworks & Libraries »
Windows Presentation Foundation »
XAML
Beginner
License: The Code Project Open License (CPOL)
A WatermarkTextBox in 3 lines of XAMLBy AndyL2Another example of how XAML can solve issues that most developers automatically assume will require "coding". |
C#3.0.NET3.0, .NET3.5, XAML, WPF, Dev, Design
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Published examples demonstrating how to create a WatermarkTextBox in WPF, including the 'InfoTextBox' control in Kevin Moore's popular "Bag-O-Tricks" sample library always seem to involve a significant amount of code-behind, when a fully-functional version can be built with just three lines of XAML, leveraging WPF's built in BooleanToVisibilityConverter.
The complete project includes two variations on this functionality.
This example stems from a discussion in a recent .NET User's Group meeting, in which several experienced WPF developers complained about the removal of the WatermarkTextBox control in the latest version of Silverlight. They all jumped to the conclusion (which I think is very common among developers) that supporting similar functionality would require "coding" a custom control of some kind.
Although this is a trivial example, I think the related question of when to use XAML vs. code (and, as possibly illustrated in my second example, knowing when you've begun to cross over into "hacking via markup"), will be one of several interesting XAML-related best practice debates on many real-world multi-developer projects -- especially when faced with a confusing mixture of seemingly random implementation choices around the third dev. cycle on a large code base.
Update: Microsoft has announced that it will add a "WaterMark" property to the TextBox in a future version of Silverlight, and has made the original WatermarkTextBox code available for download.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 25 Jul 2008 Editor: Deeksha Shenoy |
Copyright 2008 by AndyL2 Everything else Copyright © CodeProject, 1999-2010 Web21 | Advertise on the Code Project |