Search code examples
c#windows-phone-8silverlight-toolkit

Close keyboard on tapping on Enter


I use the toolkit for Windows Phone 8 and have a page with a AutoCompleteBox.

Now I want to close the keyboard if user writes something into the AutoCompleteBox without selecting a present item (meens user typed in a different text) and commits the text with "Return".

How can this be done?


Solution

  • You could do something like this,

    <AutoCompleteBox Name="Input" KeyUp="Input_KeyUp" FontSize="40">
            <AutoCompleteBox .InputScope>
                <InputScope>
                    <InputScopeName />
                </InputScope>
             </AutoCompleteBox .InputScope>
      </AutoCompleteBox >
    

    And on event,

    private void Input_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            this.Focus();
        }
    }
    

    Read whole article here : Dismiss the SIP (keyboard) in WP8