VisualElement.IsFocused Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value indicating whether this element is focused currently. This is a bindable property.
public bool IsFocused { get; }
member this.IsFocused : bool
Property Value
true
if the element is focused; otherwise, false
.
Remarks
Applications may have multiple focuses depending on the implementation of the underlying toolkit. Menus and modals in particular may leave multiple items with focus.
The following example shows conditionally setting a background color based on the focus state.
void UpdateBackground ()
{
if (myElement.IsFocused)
myElement.BackgroundColor = Color.Red;
else
myElement.BackgroundColor = Color.Blue;
}