How to create a watermark in a text box using silverlight?

Can someone explain to me how I can create a watermark in a text box using silverlight?

+3
source share
3 answers
+6
source
<Grid x:Name="SearchPanel">
    <TextBox x:Name="txtQuery" Text="{Binding Query, Mode=TwoWay}" Margin="8" Padding="3, 3, 21, 3"
        GotFocus="txtQuery_GotFocus" LostFocus="txtQuery_LostFocus"/>

    <TextBlock x:Name="lblSearchStatus" VerticalAlignment="Center" Margin="13, 0"
        Text="Enter some text ..."
        IsHitTestVisible="False">
    </TextBlock>
</Grid>

Then hide lblSearchStatus in txtQuery_GotFocus and show it again in txtQuery_GotFocus. Can also be done using storyboards. The important part is setting IsHitTestVisible to false to overlay the TextBlock.

0
source

TextBox PasswordBox.

NuGet: WindowsPhoneControls

:

https://github.com/JoshClose/WindowsPhoneControls

0

All Articles