Giving Focus to Adorners

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.

Comments (3)

  1. Doichin says:

    Hello Jim

    I faced the problem with TextBox focus and delete key.

    I saw that ActiPro software has worked this out.

    Could give me some ideas how to workaround your bug about the delete button?


  2. I’m not sure how ActiPro worked around the issue.  You might be able to write a task to handle the delete key.  I’m afraid that we don’t have a supported workaround.