How do I Set Focus in My Custom User Control?
When you create a custom user control, it typically contains child user interface elements. To provide a proper "Focus" experience at run time, you need to do the following:
- Select your user control in design mode and check the Focusable check box
- Create a handler method for your user control's GotFocus event. In the event handler method, add a line of code that sets focus to the child control you want to initially receive focus. For example:
private void AutoCompleteTextBox_GotFocus(object sender, RoutedEventArgs e)
{this.txtTextBox.Focus();}
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 10/23/10
Comment or report problem with topic
