【发布时间】:2014-07-12 02:50:44
【问题描述】:
有人可以向我解释如何使用 Silverlight 在文本框中创建水印吗?
【问题讨论】:
标签: silverlight windows-phone-7
有人可以向我解释如何使用 Silverlight 在文本框中创建水印吗?
【问题讨论】:
标签: silverlight windows-phone-7
【讨论】:
<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>
然后在 txtQuery_GotFocus 中隐藏 lblSearchStatus 并在 txtQuery_GotFocus 中再次显示。也可以通过情节提要完成。重要的部分是将 TextBlock 覆盖的 IsHitTestVisible 设置为 false。
【讨论】:
我创建了一个水印文本框和水印密码框。
在 NuGet 上可用:WindowsPhoneControls
您可以在这里查看源代码:
【讨论】: