by Administrator16. October 2010 05:56

Recently I had been battling with adorners in WPF. I have a watermark service adapted from the code in this SO answer, which works great, adding watermarks to my text boxes.

However sometimes user controls that are shown above a textbox with a watermark on it would show the watermark above everything else, which became pretty annoying.

After some research with google and snoop, I discovered how adorners work, and the fact that when an adorner is added to an element, it is in fact added to the first adorner decorator up the tree, and because by default the adorner decorator is right at the top of the tree the adorners appear over everything.

The simple fix is to add an adorner decorator around the specific element with the watermark, that way the watermark stays with the element.

For example:

<AdornerDecorator Grid.Row="0" Grid.Column="1">
	<TextBox x:Name="UsernameTextbox" Text="">
			<TextBlock Text="Username"/>


Visual Studio 2010 Handy Hints

by Administrator16. October 2010 05:41

Discovered this today, I knew it could be done, but hadn't bothered to google for the right shortcut:

Ctrl-Shift-F12 - Navigate to the next error in the error list.



About the author

Something about the author

Month List

Page List