I have a usercontrol loaded inside a canvas; this usercontrol on default have visibility collapsed. When a specific textbox of my window is focused the usercontrol become visible.
When usercontrol become visible I want set focus to another textbox inside usercontrol.
I try to do that:
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.Visibility == Visibility.Visible)
{
FocusManager.SetFocusedElement(this, TextBlockInput);
}
}
It seems work but there is a problem: the textbox seems focused but the cursor into textbox don't blink and I can't type chars for input.
I would that after focus the textbox is ready for input. How can I do?
try
see here for more details
Another possible workaround is instead of
Visibility
property useOpacity
. In this case callingFocus()
actually sets focus.Well, I solve in this way:
I think that the problem was tha focus call into IsVisibleChanged event "scope"...right?