XAML only WPF Watermarked TextBox
|
|
||||||||||||||||
Descriptionand we want that; a watermark should visually appear on top of a textbox. On our TextBlock however, we don't want it be included in any hit test results, so we'll set the IsHitTestVisible property to false.
For theTextBlock's style, we'll default it to collapsed, and then set it to visible when our DataContext's Text property does not have content AND when the TextBox does not have keyboard focus. And that's it! No converters, no extensions, just pure XAML. |
Sponsored links
File list
Tips: You can preview the content of files by clicking file names^_^Name | Size | Date |
---|---|---|
WatermarkExample.sln | 1,017.00 B | 2015-03-04|22:11 |
0 | 1.97 kB | |
App.config | 189.00 B | 2015-03-04|22:11 |
App.xaml | 587.00 B | 2015-03-04|22:11 |
App.xaml.cs | 349.00 B | 2015-03-04|22:11 |
MainWindow.xaml | 2.18 kB | 2015-03-04|22:11 |
MainWindow.xaml.cs | 682.00 B | 2015-03-04|22:11 |
packages.config | 296.00 B | 2015-03-04|22:11 |
0 | 1.97 kB | |
AssemblyInfo.cs | 2.24 kB | 2015-03-04|22:11 |
Resources.Designer.cs | 2.79 kB | 2015-03-04|22:11 |
Resources.resx | 5.48 kB | 2015-03-04|22:11 |
Settings.Designer.cs | 1.08 kB | 2015-03-04|22:11 |
Settings.settings | 201.00 B | 2015-03-04|22:11 |
0 | 1.97 kB | |
MainViewModel.cs | 1.60 kB | 2015-03-04|22:11 |
ViewModelLocator.cs | 1.36 kB | 2015-03-04|22:11 |
WatermarkExample.csproj | 5.53 kB | 2015-03-04|22:11 |
Sponsored links
Comments
(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words
qiuchenzhimeng
2015-04-23
多謝樓主的分析哈,非常感謝。這個文件對我非常有用,消除鋸齒效果很不錯
2063162649
2017-01-20
多謝樓主的分析哈,非常感謝。這個文件對我非常有用,消除鋸齒效果很不錯
- 1
- Page 1
- Total 1