Control.FocusState property

Expand Minimize
This topic has not yet been rated - Rate this topic

Gets a value that specifies whether this control has focus, and the mode by which focus was obtained.

Syntax


public FocusState FocusState { get; }

Property value

Type: FocusState

A value of the enumeration. A value of Unfocused indicates that the control does not have focus.

Remarks

This property supports controls that use different visual styles depending on whether the control was focused by the keyboard or by other means. Some controls use visual states that show a visible focus indicator if the control was focused by a keyboard action, but do not show the indicator if the control was focused by a pointer action. The internal logic of such a control implements OnGotFocus and then gets the value of FocusState from the sender. If FocusState is Keyboard, then a different named visual state that includes a focus rectangle is loaded, by calling GoToState. Typically, focus-related visual states are grouped together in the default control template XAML. Custom controls that want to use different focus visuals depending on the means of focus can implement this same logic themselves. See OnGotFocus.

Another way to use this property is to use FocusManager to determine which element in the overall UI has focus, and then call FocusState on that element to get information on how that control received focus.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

Control

 

 

Build date: 3/12/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.