1

我正在使用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);
}

问题是我想在用户按下它并进行搜索时获取选定的字符串,但是每次用户向文本框输入新字符时都会调用函数“SearchBoxDidSelectItem”。知道如何解决吗?我怎样才能获得点击项目的方法?

4

0 回答 0