Home > Software design >  Which control has the focus in my WPF window, how to find this in Live Visual Tree?
Which control has the focus in my WPF window, how to find this in Live Visual Tree?

Time:01-28

I'm starting to work with a GUI related application in WPF.

I'm using the Live Visual Tree in Visual Studio to investigate the controls on my WPF window.
I know how I can find a control in the Live Visual Tree and see its attributes, but I can't do the other way around:

I am selecting a control on my WPF window while debugging (it's a button), and I would like Visual Studio to open/select/show/jump to that particular control in the Live Visual Tree. Is that even possible?

CodePudding user response:

First, you have to enable the in-app toolbar for hot reload. Go to Tools > Options... in the menu. From there, select Debugging > Hot-Reload in the settings tree view. Tick the Enable in-app toolbar option.

Hot-Reload options with the enable in-app toolbar checkbox.

Then start debugging. At the top of your window, a black bar with buttons will appear. Select the Track Focused Element toggle button. After that, the Live Visual Tree will automatically jump to the currently focused element.

In-App bar in debugging mode with option to track the focused element.

  •  Tags:  
  • Related