Giving Focus to Adorners

Giving Focus to Adorners

  • Comments 3

If you add a TextBox as an adorner to your design time, by default you will not be able to give that TextBox focus.  That is, you won't be able to set the cursor in it so that you can type.

Similarly, if you use a TabControl as an adorner, by default you won't be able to switch the tabs by clicking on them.

The solution is to set the AdornerPanel.IsContentFocusable property to true:

            AdornerPanel ap = new AdornerPanel();
            ap.IsContentFocusable = true;

One caveat here: we know we have a bug in the TextBox keyboard handling where the delete key will always delete the selected control, even when the user is in text entry mode in a TextBox -- i.e. hitting the delete key won't delete the text, it will delete the control.

Leave a Comment
  • Please add 8 and 3 and type the answer here:
  • Post
Page 1 of 1 (3 items)