Control.Focus Method
Attempts to set the focus on the control.
Namespace: System.Windows.Controls
Assembly: System.Windows (in System.Windows.dll)
Return Value
Type: System.Booleantrue if focus was set to the control, or focus was already on the control. false if the control is not focusable.
Calling Focus raises the GotFocus or LostFocus events on appropriate elements if focus actually changed (a true return value and focus was not already on that control).
In order to be focusable, the following must be true:
Visibility is set to Visible.
-
IsTabStop is set to true.
-
IsEnabled is set to true.
-
The control must be instantiated in the tree (the Loaded event has fired and the control connects to the root object that is the Silverlight plug-in content).
Although the "FocusedElement" value (exposed via GetFocusedElement method) is updated immediately, the change notifications of GotFocus and LostFocus occur asynchronously. This asychronous focusing design is intended to assure that elements that are created at run-time do not fail in calls to Focus because the acting FocusManager was not updated to the latest view of the visual tree.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.