ContentElement.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 that determines whether this element has logical focus.

C#
public bool IsFocused { get; }

Property Value

true if this element has logical focus; otherwise, false.

Examples

The following example creates a style that makes a Paragraph focusable by default and gives it a visual behavior when it receives focus.

XAML
<Style x:Key="FocusableParagraph" TargetType="{x:Type Paragraph}">
  <Setter Property="Focusable" Value="true"/>
  <Style.Triggers>
    <Trigger Property="IsFocused" Value="True">
      <Setter Property = "Background" Value="{StaticResource BlueGreenBrush}"/>
    </Trigger>
  </Style.Triggers>
</Style>

Remarks

Logical focus might differ from keyboard focus if an application has multiple focus divisions, such as between menu contents and the remainder of the application. In this scenario, keyboard focus can only be on one element of the application UI, however, certain elements in other focus divisions might still retain logical focus. For more information on logical focus, see Input Overview and Focus Overview.

Dependency Property Information

Item Value
Identifier field IsFocusedProperty
Metadata properties set to true None

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also