Search code examples
windows-phone-7sipwindows-phone

How can I tell when the "search" button is clicked when I set InputScope to search?


For Windows Phone. How can I tell when the "search" button is clicked when I set InputScope to search on a TextBox? Is there an event?


Solution

  • When the InputScope is set to "Search", the "search" button is just a restyled "enter" button. So, assuming:

    <TextBox InputScope="Search" KeyDown="SearchBox_KeyDown" />
    

    the "search " button being pressed (on the SIP) can be detected with:

    private void SearchBox_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            // Do search...
        }
    }