AutoCompleteBox cannot set focus on load

Editors for WPF Forum

Posted 6 years ago by Mike
Version: 17.2.0665
Platform: .NET 4.7
Environment: Windows 10 (64-bit)


I have a window with the autocompletebox and I'm trying to set the focus to it to it so the user can type right away. While it works on any control such as textbox it doesn't work on the autocompletebox.

 public TestWindow()
            DataContext = this;
            autoCompleteBox.Text = "test";

 I always have to press TAB once to set the focus after the window has been created. Is there another way to set the focus to it?

Comments (1)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Mike,

Thanks for letting us know about that.  We've fixed it for the next build, which will likely be the first 2018.1 build.  Even so, you will have to do the focus call in TestWindow.Loaded since the TextBox in the AutoCompleteBox's Template hasn't loaded yet at the time you call it above.

You could probably work around it in the current version by waiting until the control's template has loaded and then using our VisualTreeHelperExtended.GetDescendant method to locate the contained TextBox, and focus that.

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.