WPF: Setting Focus in a 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:

1. Select your user control in design mode and check the Focusable check box

2. 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)

Best Regards,
Kevin McNeish
INETA Speaker
Chief Software Architect, MM .NET Application Framework

Leave a Reply

Your email address will not be published. Required fields are marked *