Focus on TextBox when UserControl change Visibility
Well, I solve in this way:
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e){ if (this.Visibility == Visibility.Visible) { this.Dispatcher.BeginInvoke((Action)delegate { Keyboard.Focus(TextBlockInput); }, DispatcherPriority.Render); }}
I think that the problem was tha focus call into IsVisibleChanged event "scope"...right?
Another possible workaround is instead of Visibility
property use Opacity
. In this case calling Focus()
actually sets focus.