Reputation: 1858
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?
Upvotes: 0
Views: 218
Reputation: 2616
You can close the keyboard using a KeyUp event handler and then selecting Focus() of the current page:
void textBox_KeyUp(object sender, KeyEventArgs e)
{
// if the enter key is pressed
if (e.Key == Key.Enter)
{
// focus the page in order to remove focus from the text box
// and hide the soft keyboard
this.Focus();
}
}
Upvotes: 1
Reputation: 222582
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
Upvotes: 3