Share via


Common input problems

When debugging input problems in Avalon, there’s a couple things I always look for first.  If I’m not getting keyboard input:

  • Does my control actually have focus?  Make sure IsFocusWithin property is true.
  • Is someone handling the event before it gets to me?  You can use the Preview* series of events to watch earlier (although unless you hook up at the root, someone may still beat you to the event).  Or you can use AddHandler to watch for handled as well as unhandled events.

If I think I should have focus but I don’t:

  • Is my control focusable?  See IsFocusable property.
  • Did I ask for focus?  Only subclasses of Control will automatically ask for focus when you click on them.  Other classes need to explicitly call SetFocus.

If I’m not getting mouse input:

  • Is my control transparent?  If so, did I use Background=null (invisible to the input System, and the default for many controls), or Background=”Transparent”, which the input system can see and click on?
  • Is your control or one of its parents disabled (IsEnable = false)?