我有以下代码:
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);
});
}
但是单击时,RichEditBox 没有获得焦点。我的代码有什么问题?谢谢
对不起,我忘了添加这个代码:“MsgWebView.NavigateToString("Hello World!");”。我发现问题出在这。所以整个代码是这样的:
private void SendMsg_Click(object sender, RoutedEventArgs e)
{
MsgWebView.NavigateToString("Hello World!");
SendBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
}
如何解决这个问题呢?此致。