views:

468

answers:

1

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;
}
+4  A: 

You have to use FocusManager

bool b = FocusManager.GetFocusedElement() == textBox;
Rob Fonseca-Ensor
Thanks. I wonder why Microsoft decided to handle it this way instead of the way it's handled everywhere else (even their own products)...
Dov
Maybe it helps keep the installer smaller?
Rob Fonseca-Ensor