开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜