Reputation: 12194
I have a WPF app that uses different instances of a User Control; when the user clicks a button on the main window I need to set the focus on the textbox inside the currently active instance of the user control.
Which is the best way to set the focus on that child item?
Upvotes: 1
Views: 835
Reputation: 8394
child.Focus();
or
VisualTreeHelper.GetChild(parent, 0).Focus(); // you might want to test it for nulls
Upvotes: 1