Is there any way to tell whether a control (specifically a System.Windows.Controls.TextBox) is focused in Silverlight? I'm looking for something like the following (what you would see in a regular .Net application):
textBox.Focused
This seems like something simple and trivial to leave out from a control, and yet I can't find an answer anywhere.
Update
A slightly more elegant solution, incorporating Rob's answer, is to create an extension method like so:
public static bool IsFocused( this Control control )
{
return FocusManager.GetFocusedElement() == control;
}
You have to use FocusManager
bool b = FocusManager.GetFocusedElement() == textBox;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With