* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
1.9 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Add a Watermark to a TextBox | 03/30/2017 |
|
|
df89bdd8-a0fb-45e0-b312-dd53332d01a8 |
How to: Add a Watermark to a TextBox
The following example shows how to aid usability of a xref:System.Windows.Controls.TextBox by displaying an explanatory background image inside of the xref:System.Windows.Controls.TextBox until the user inputs text, at which point the image is removed. In addition, the background image is restored again if the user removes their input. See illustration below.
Note
The reason a background image is used in this example rather then simply manipulating the xref:System.Windows.Controls.TextBox.Text%2A property of xref:System.Windows.Controls.TextBox, is that a background image will not interfere with data binding.
Example
[!code-xamlTextBoxMiscSnippets_snip#TextBoxBackgroundExampleWholePage]
[!code-csharpTextBoxMiscSnippets_snip#TextBoxBackgroundCodeExampleWholePage] [!code-vbTextBoxMiscSnippets_snip#TextBoxBackgroundCodeExampleWholePage]
