GuOrg / Gu.Wpf.Adorners

MIT License
90 stars 12 forks source link

Generalized watermark #89

Open bent-rasmussen opened 2 years ago

bent-rasmussen commented 2 years ago

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="&#xE721;" />
            <TextBlock Text="Search">
                <TextBlock.RenderTransform>
                    <TranslateTransform Y="-1" />
               </TextBlock.RenderTransform>
            </TextBlock>
       </TextBlock>
   </uc:WatermarkService.Watermark>
</TextBox>
JohanLarsson commented 2 years ago

Maybe the overlay is a fit for this use case?

bent-rasmussen commented 2 years ago

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.