Reputation: 137
Can someone explain to me how I could create a watermark in a textbox using silverlight?
Upvotes: 3
Views: 1707
Reputation: 23383
I created a watermark TextBox and watermark PasswordBox.
It's available on NuGet: WindowsPhoneControls
You can look at the source here:
https://github.com/JoshClose/WindowsPhoneControls
Upvotes: 0
Reputation: 10296
<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. Could be also done via storyboard. The important part is setting IsHitTestVisible to false for the TextBlock overlay.
Upvotes: 0
Reputation: 5885
Here is what you need. http://watermarktextbox.codeplex.com/
Upvotes: 6