This is a migrated thread and some comments may be shown as answers.

How can I find the what element is being focused on in a WPF application?

4 Answers 1377 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gnuftw
Top achievements
Rank 2
gnuftw asked on 28 May 2015, 07:25 PM

I am working with a WPF application. I am curious if it is possible to detect if a certain element in the UI is under focus?

The attached screenshot shows 2 fields, the 1st of which has focus. The 2nd one does not.

I found a similar post but it was slightly out of date and I was not sure if it discussing WPFs here: Finding Focus.

~ Max

4 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 01 Jun 2015, 07:48 PM
Hello Max,

First I can confirm the post you reference was talking about testing a WPF application. It is still true that there is no way how to check if the element is focused.


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
gnuftw
Top achievements
Rank 2
answered on 02 Jun 2015, 03:11 PM

Bummer!

Does test studio allow one to get a reference to a WPF UI element in a running application?

If so, I will be able to test focus.

~ Max

0
gnuftw
Top achievements
Rank 2
answered on 02 Jun 2015, 08:13 PM

Hey Cody,

 We are testing a possible text box for use in our application. Interestingly enough, this control of type RadNumericUpDown has a focus verification option as you can see in the attached screenshot

Is it expected that the RadNumericUpDown has this but a RadButtons or RadOutlookBars do not?

If Test Studio has no way to check what element is focused, what am I seeing here?

Is it in Telerik's road map to make element focus check able?

~ Max

0
Cody
Telerik team
answered on 02 Jun 2015, 10:02 PM
Hello Max,

I didn't even know that functionality existed (too many features for me to keep track of them all). That works but only for some of the Telerik Rad controls which have an available translator, as you have already discovered. It won't work for just any UI element in a WPF application. You can use it only to tell if that specific control currently has the input focus at that point in time. It cannot be used to discover which element currently has input focus.

I am not aware of plans in the immediate future to expand on the "has focus" verification.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
gnuftw
Top achievements
Rank 2
Answers by
Cody
Telerik team
gnuftw
Top achievements
Rank 2
Share this question
or