2

Suppose I have an element (in my case, a StackPanel) that contains several UI elements (in my case, lots of textboxes contained in various Grids contained in etc.etc. contained in the StackPanel).

I want to know whether any one of those textboxes has focus. (I want to bind this property to a View-Model property.) Is there a property for this? If not, what is the simplest way to bind to this kind of information, without having to first extract all the textboxes? (They’re generated by templates.)

1 Answer 1

2

You could use IsKeyboardFocusWithin. What kind of binding are you wanting to do to it? If it's something simple like you're wanting to change the background of the stackpanel if a textbox within has focus, you should be able to use this as a style trigger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.