Reputation: 66573
Suppose I have an element (in my case, a StackPanel
) that contains several UI elements (in my case, lots of textboxes contained in various Grid
s 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.)
Upvotes: 2
Views: 243
Reputation: 10416
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.
Upvotes: 2