Focus Textbox using FocusManager.FocusedElement issue

爱⌒轻易说出口 提交于 2019-12-05 15:30:19
artos

After FocusManager is setting the focus you have to handle this event and in the event you have to add

<TextBox x:Name="TxtB" 
         Text="B" 
         GotFocus="TxtB_GotFocus"  
         Visibility="{Binding IsEditMode
             , Converter={StaticResource BoolVisibilityCollapsed}}"/>

....
private void TxtB_GotFocus(object sender, RoutedEventArgs e)
{
    this.Dispatcher.BeginInvoke((Action)delegate
    {
       Keyboard.Focus(TxtB);
    }, DispatcherPriority.Render);
}

Thanks a lot to Darlene

And I'm adding the answer by myself to meet Sheridan's suggestion Thanks a lot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!