Gu.Wpf.Adorners
Gu.Wpf.Adorners copied to clipboard
Generalized watermark
Improvement suggestion:
The watermark adorner looks great, however it seems like there is a limitation in terms of what it can display. I have a use-case where I want to show a magnifier glass symbol before the text "Search". In order to display the magnifier glass I need to be able to set the font family to Segoe MDL2 Assets. This does not appear possible in the current implementation. Do you like the idea of having a TextBlock property type here?
Here's how I do it with the current buggy watermark implementation I use:
<TextBox Text="{Binding Path=Foo}">
<uc:WatermarkService.Watermark>
<TextBlock>
<Run FontFamily="Segoe MDL2 Assets" Text="" />
<TextBlock Text="Search">
<TextBlock.RenderTransform>
<TranslateTransform Y="-1" />
</TextBlock.RenderTransform>
</TextBlock>
</TextBlock>
</uc:WatermarkService.Watermark>
</TextBox>
Maybe the overlay is a fit for this use case?
Maybe, it just sounded like watermark was the correct adorner because it can hide the text when the user enters text into the textbox - but I will take a look at that - or experiment with customizing the watermark adorner.