是否可以在“提示”中添加“提示”?在 Windows Phone 7 文本框中?
我在 Android 上编程了大约半年之后,才刚刚开始为 Windows Phone 7 编程。在 Android 中,当我需要用户输入文本时,我会在文本框中放置一个“提示”,告诉用户应该输入什么。当选择文本框时,提示将消失。到目前为止,我只见过在文本框中设置文本的方法。这样做的问题是,当用户选择文本框时,文本不会消失,迫使用户删除当前存在的文本。
我做了一些谷歌搜索并浏览了相关文档以及我拥有的一本书,但我还没有找到答案。预先非常感谢您抽出时间回答我的问题。
I just got started programming for Windows Phone 7 after programming on Android for about half a year now. In Android, when I wanted textual input from a user, I would put a "hint" in the text box which would tell the user what they should input. When the text box was selected the hint would disappear. So far I've only seen ways to set text inside text boxes. The problem with this is that the text does not disappear when the user selects the text box forcing the user to erase the currently existing text.
I did some Google searches and skimmed through relevant documentation as well as a book I have but I've not found an answer yet. Thank you very much in advance for your time answering my question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的内容通常称为“带水印”文本框。创建实现此功能的控件非常简单。
以下是一些实现版本的链接:
What you're looking for is normally called a "Watermarked" textbox. It's quite simple to create a control which implements this functionality.
Here are links to a few versions of implementations of this:
据我了解,您想要类似于搜索框中的默认文本(stackoverflow.com 的右上角)的内容。
你有几个选择。
布尔值检查用户是否第一次按下文本框。
并在事件内部(双击文本框)
使用不同的视觉状态定义您自己的模板。
您可以使用一些 WPF 示例
如何实现默认文本WPF 中的搜索框?
As I understand you want something similar to the default text in the searchbox (upper right corner of stackoverflow.com).
You have a few options.
Bool to check if user press the TextBox for the first time.
and inside the event (double click the TextBox)
Define your own template with a diffrent visual state.
You could use some WPF examples
How do you implement default text for a search box in WPF?