How to set the focus on a user control item in WPF?
I have a WPF app that uses different instances of a User Control; when the user clicks a button on the mai开发者_StackOverflow中文版n 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?
child.Focus();
or
VisualTreeHelper.GetChild(parent, 0).Focus(); // you might want to test it for nulls
精彩评论