Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anyone have a good way to debug WPF focus?

I'm going to focus hell right now in my WPF application. Focus is jumping around between elements, and seemingly disappearing only to come up on another element when the tab key is repeatedly pressed.

Is there a property I can bind a label on to or something that will simply just tell me what the heck the keyboard focus is latched on to at the time? Sometimes I can see the ant trail (dotted line) indicating something has focus, but I can't tell what it is surrounding to turn the keyboard focus off!

like image 688
Jippers Avatar asked May 05 '09 18:05

Jippers


1 Answers

What you are likely looking for is:

(System.Windows.Input.Keyboard.FocusedElement as FrameworkElement).Name

You will have to setup a DependencyProperty for it so that you can bind to it though.

Vaccano

like image 65
Vaccano Avatar answered Oct 16 '22 14:10

Vaccano