Windows Phone 7 ListBox 事件混淆
该应用程序就像一本小词典。我有一个列表框和一个文本框。列表框已填充有单词,当文本框中有任何条目时,列表框将再次填充以文本框中的字母开头的单词。我有一个列表框 SelectionChanged 事件,当用户单击一个单词时,它的含义就会出现。问题是,当用户从列表中选择一个单词,然后在文本框中键入某些内容时,将调用 listBox SelectionChanged 事件,我不希望发生这种情况,因为此时我的列表框的所选项目为空。我想要一个事件仅当用户从列表框中选择某些内容时才会触发。当列表框的内容更改时不应触发它。谢谢
The app is like a small dictionary. I have a listbox and a textbox. The list box is already filled with words and when there is any entry in the textbox the listbox is refilled again with words starting with the letters in the textbox. I have a listbox SelectionChanged event implemented when the user clicks on a word its meaning appears. The problem is when user selects a word from the list and then types something in the textbox, listBox SelectionChanged event is called i dont want this to happen because at this point of time my listbox's selected item is empty.I would like to have a event that is fired only when user selects something from the listbox. It should not be fired when the content of the listbox changes. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
1.if (lstWords.SelectedItem != null)
2.lstWords.SelectedIndex = -1;
例如< /strong> 以下是文本更改事件和列表选择更改事件的源代码
You can use
1.if (lstWords.SelectedItem != null)
2.lstWords.SelectedIndex = -1;
for e.g. following is the source code for text changed event and list selection change event