我正在使用AutoCompleteBox
:
<my:AutoCompleteBox Grid.Column="1" Name="SearchTextBox" Height="23" Width="240"
Populating="SearchTextDidChange" FilterMode="None" SelectionChanged="SearchBoxDidSelectItem" />
这就是方法:
private void SearchTextDidChange(object sender,System.Windows.Controls.PopulatingEventArgs e)
{
if (!String.IsNullOrEmpty(SearchTextBox.Text))
{
google.GetSuggestFromGoogle(SearchTextBox.Text);
}
}
private void SearchBoxDidSelectItem(object sender, SelectionChangedEventArgs e)
{
AutoCompleteBox item = (AutoCompleteBox)sender;
string searchString = (string)item.SearchText;
this.SendSearchRequest(searchString);
}
问题在于,当用户按下它并进行搜索时,我想获取所选字符串,但每次用户向TextBox输入新字符时,都会调用函数“SearchBoxDidSelectItem”。知道怎么解决吗?如何获得点击项目方法?