Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElement.Focusable Property

Gets or sets a value that indicates whether the element can receive focus. This is a dependency property.

Namespace: System.Windows
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public bool Focusable { get; set; }
/** @property */
public final boolean get_Focusable ()

/** @property */
public final void set_Focusable (boolean value)

public final function get Focusable () : boolean

public final function set Focusable (value : boolean)

<object Focusable="bool" .../>

Property Value

true if the element is focusable; otherwise false. The default is false, but see Remarks.

Identifier field


Metadata properties set to true


Only the focused element receives keyboard input.

Focusable is the Microsoft .NET property accessor for what is in reality a dependency property. This particular dependency property quite frequently has its apparent "default" value set differently in derived element classes, particularly in controls. This commonly occurs in one of two ways: the dependency property is inherited by a particular derived class, but that derived class overrides the metadata of the dependency property that sets its default value; or there is a style being applied that sets that dependency property value differently. For example, the apparent "default" of Focusable for a Button control will be true, even though Button inherits Focusable as a common language runtime (CLR) property directly from UIElement. This is because the applied metadata value for the Focusable dependency property was overridden within the static constructor of the Control base class, which is situated between Button and UIElement in the class hierarchy.

When inherited by Control or its derived classes, Control redefines the default value of this property to be true.

When inherited by Label and Canvas (both of which are Control derived classes) the default value is again redefined to be false.

Notes to Inheritors: When deriving from UIElement directly (as opposed to from Control), consider whether you wish your element to be focusable, because by default it will not be. If you wish your element to be focusable, override the metadata for this property within your type's static constructor as follows:

FocusableProperty.OverrideMetadata(typeof(myElement), new UIPropertyMetadata(true));

where myElement should be the class name of the type that you are overriding the metadata value on.

The following example code illustrates a control template for a particular custom control, which sets Focusable false on one of the elements within the template.

  <Style x:Key="TextBoxNoScrollViewer" TargetType="{x:Type TextBoxBase}">
    <Setter Property="Template">
        <ControlTemplate TargetType="{x:Type TextBoxBase}">
            Background="{TemplateBinding Background}" 
            BorderThickness="{TemplateBinding BorderThickness}" 
            BorderBrush="{TemplateBinding BorderBrush}"  
            The control template for a TextBox or RichTextBox must
            include an element tagged as the content host.  An element is 
            tagged as the content host element when it has the special name
            PART_ContentHost.  The content host element must be a ScrollViewer,
            or an element that derives from Decorator.  

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2017 Microsoft