Reputation: 11
I have the following code:
private async void SendMsg_Click(object sender, RoutedEventArgs e)
{
RichEditBox.Document.SetText(TextSetOptions.None, "");
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
if(RichEditBox!=null)
SendBox.Focus(Windows.UI.Xaml.FocusState.Keyboard);
});
}
but when clicked,the RichEditBox didnot got focus.What's wrong with my code? thanks
Sorry,I forgot add this code:"MsgWebView.NavigateToString("Hello World!");".And I found the problem lies in here.So the whole code is like this:
private void SendMsg_Click(object sender, RoutedEventArgs e)
{
MsgWebView.NavigateToString("Hello World!");
SendBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
}
How to solve this problem? Best regards.
Upvotes: 1
Views: 2168
Reputation: 45127
You need to use the Programmatic option on FocusState (not Keyboard).
SendBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
Upvotes: 2