Control Control Control Class

Definition

Represents the base class for UI elements that use a ControlTemplate to define their appearance. Parent class for ContentControl, UserControl, ItemsControl and several practical controls.

public : class Control : FrameworkElement, IControl, IControl2, IControl3, IControl4, IControl5, IControlOverrides, IControlOverrides6, IControlProtected
public class Control : FrameworkElement, IControl, IControl2, IControl3, IControl4, IControl5, IControlOverrides, IControlOverrides6, IControlProtected
Public Class Control Inherits FrameworkElement Implements IControl, IControl2, IControl3, IControl4, IControl5, IControlOverrides, IControlOverrides6, IControlProtected
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The Control class is the base class for many of the controls you add to an app and its UI. The Control class defines very little behavior; you can add an actual Control element to XAML for UI but you typically add something that inherits from Control directly or indirectly, such as a Button or ListBox. For a list of controls you can use, see Controls by function.

The Template property, which uses the type ControlTemplate, specifies the visual appearance of a control. If you want to change the appearance of a control but retain its functionality, you should consider creating a new ControlTemplate instead of defining a new Control -based class. For more info, see Quickstart: Control templates.

Control is the parent of UserControl. UserControl is the intended base class for lightweight controls that don't need visual states. Although the UserControl technically inherits the Template property, you cannot apply a template to a UserControl.

Implicit styles for controls

Each practical control that's defined for XAML has a default style that contains its default control template. Controls can have an implicit style, meaning that the FrameworkElement.Style property isn't set explicitly. Once that implicit style is available, almost all other properties of a control can be set with Setter elements in that Style. The Style can initialize the control separately from the rest of the control logic, and can set values that aren't the code-based defaults for each property.

The implicit style exists as a keyed resource that's part of the Windows Runtime, stored internally as a binary representation of XAML. You can get a copy of either a particular control's style or of the full set of styles to look at how the styles and control templates are defined.

The association between a particular control type and the key/name of the implicit style it uses by default is established by the value of the DefaultStyleKey property. The DefaultStyleKey property is protected, so only someone that subclasses a control class can change the value. If you're just creating a control instance, for example declaring controls in a XAML UI, then the default style is the implicit style that's based on the control's type. For more info, see Remarks in DefaultStyleKey. You don't need to change the DefaultStyleKey value to use a different style, you just need to define your own XAML Style that has the same TargetType that matches the implicit style lookup and exists as a XAML resource. For more info, see Quickstart: Control templates.

The visual state model

The visual state model is a technique where you modify just a few of the properties defined in a control's template. You change property values in order to provide visual feedback to the user that indicates what the control is doing and hints at further UI interactions that are possible. The controls are modified by applying zero-duration or short-duration storyboarded animations to some of the properties in the template. You also can define short-duration animations that apply for the transitions between states.

The visual states themselves are defined as part of the control template. Each visual state has a name, so that the control logic can invoke the GoToState method that loads up each visual state when it's needed for a particular logic state. Visual states are declared within visual state groups, so that visual states that are exclusive to each other can ensure that only one such state is active at a time. As soon as another visual state from the same group is loaded, the animations for the previous state stop being applied, but animations in another group might still be running and applying their changes and visual behavior. For example, a control might have a visual indicator for keyboard focus and a visual indicator for pointer-over. Because these are UI modes that can be adjusted independently of each other and can happen at the same time, they're each defined in a different visual state group.

Because it's defined in XAML as part of the control template, you can change the visual state behavior for any XAML control that you use in your UI. However, the logic is still based on the control expecting to find certain visual state groups and named visual states within. So you have to be very careful that you're providing the correctly named and structured visual states that are showing all aspects of a control's behavior to the user. For more info, see Storyboarded animations for visual states. Visual states are also briefly introduced in Quickstart: Control templates.

Default visual states for controls sometimes use the library animations. You should try to preserve the library animations when you replace control templates or visual states because these animations are an important part of the control's look and feel in the UI. For more info, see Animations overview.

Controls and focus

The Control class defines several API that influence the keyboard focus behavior for a UI: the Focus method, the FocusState property, and the IsEnabled and IsTabStop properties. Enabling keyboard focus is an important part of assuring that a UI is accessible, because each focusable element becomes part of the tab order for the UI. Only UI elements that are interactive are typically enabled to receive keyboard focus. For example, a TextBox is interactive because the user can type text, whereas a TextBlock is not interactive because the text is read-only. Most of the classes that derive from Control are legitimately interactive and so it makes sense that they can be focused and should be in the tab order.

In order to be focusable, each of these must be true:

  • Visibility is Visible
  • IsEnabled is true
  • IsTabStop is true
  • The control must be instantiated with its template loaded (Loaded fired, control connected to app's root visual) If you want a control to not be focusable, you can set IsTabStop to false. However, if the reason you don't want the control to have focus is because it's not interactive in your UI, you might want to set IsEnabled to false to make the lack of interaction obvious to everyone. Many controls have predefined visual states that are invoked for IsEnabled =false, such as "graying out" text in labels.

Focus changes can fire GotFocus or LostFocus events. Although the "FocusedElement" value (exposed via GetFocusedElement method) is updated immediately, the change notifications of GotFocus or LostFocus occur asynchronously. This asynchronous focusing design is intended to avoid flickering on visual state transitions when control logic reacts to focus change too quickly.

The Focus method enables bringing keyboard focus to a control programmatically. Be judicious when calling this method, it can be intrusive to move the keyboard focus when the user doesn't expect it. The main scenarios for Focus are either setting the very first keyboard focus point when an entire page of UI is loaded, or setting focus to a specific part of a control once the parent control container has received top-level focus (like focusing the textbox in a combobox). For more info, see Focus. FocusState tracks whether focus is programmatic or user-driven, which makes a difference for visual states, notably the visual focus indicator for keyboard focus that all controls should have.

On* event handler overrides

Each On* method represents a prewired event handler for the corresponding UIElement event. Practical controls that derive from Control can override the On* method and use this to provide control-specific handling and behavior for that input event. The most common scenario is to use the event handler to mark the event as Handled in the event data. The control code has first chance to handle this event, before any event handlers that are wired on a control instance are invoked. When the event data is marked Handled, then other handlers like those on the control instance won't be called. Also, the event won't bubble.

As it's implemented directly on Control, the On* method has an empty implementation. But each ancestor in a control's hierarchy may have provided an implementation. You won't be able to see this implementation because it's internal native code. In some cases a control will already have existing On* overrides that mark the event Handled. Once you've provided an initial On* override for a control, then any controls that you further derive from your own control class would also inherit the On* overrides you define. Any instances you use have that behavior too.

Note

App code can still handle events that may have been marked Handled by a control's On* method logic, but they need to use the handledEventsToo parameter for the UIElement.AddHandler method. For more info, see UIElement.AddHandler or Events and routed events overview.

The Control class defines several protected virtual methods that are each associated with a framework-level input event. These methods are intended to provide a pre-wired event handler for input events such that a control can enforce that certain input behaviors are used by that control and all instances of it. For example, there's a PointerPressed event defined by UIElement. Control defines the OnPointerPressed method, with an empty definition. Within the base Control constructor, event wiring for all the relevant input events includes the On* method as a listener/handler, which initially does nothing. But all it takes now for you as the control author to change the behavior for an input event is to give a new override definition for an On* method (also, make sure your constructor calls base). That behavior gets inherited to all instances or subclasses, unless another subclasser overrides it again. Because the On* events are first in sequence, before any UI definition XAML, they can adjust the event data and potentially change the conditions that other listeners see about the event.

The existing On* definitions in a particular control class can affect you as the consumer of the control even if you haven't overridden any On* methods yourself. This is because the existing On* definitions may have provided handling for an event that sets a Handled property value to false in some event's event data. That will prevent your instance-based event handling from even seeing the event, and will prevent your handler from being invoked. What's happening here is that there's an intentional control design that is enforcing that certain events shouldn't matter to the control, either because they're low-level events that clash with control logic or because the control has replacement logic. A prominent example of this is the ButtonBase class. The ButtonBase class has two behaviors that it enforces through a native override of OnPointerPressed and OnKeyDown. It's doing this because it's combining various input modes at a low level and reporting them instead as the control-specific Click event. In the case of a PointerPressed event handler, if you tried to handle this on a Button instance, your handler doesn't get invoked. That's because the native OnPointerPressed set Handled to true and that prevented PointerPressed from propagating to your instance and app code. For OnKeyDown, the logic was just looking for certain keys (Ctrl and Enter) so an instance handler can still invoke as long as it isn't also looking for those keys.

Note

There's actually a way to get around native handling of On* methods for input, for some of the input events. To do this you need to wire your handlers using the AddHandler method with handledEventsToo. For more info see AddHandler or Events and routed events overview.

Text properties that inherit to text element parts

Control defines several properties that are relevant to presentation of text. These are:

Obviously, not every control is intended to display text within it. For example, setting FontFamily on an AppBarSeparator is legal but has absolutely no effect. The reason that Control defines these properties at the base class level is to make it easy for control templates to use {TemplateBinding} markup extension to apply top-level text properties to one or more text element parts that exist within the template. For example, if you look at the control template for a DatePicker, you'll see that the root is a container and more deeply within that container are several ComboBox parts that actually take the text input. Each of these uses statements like FontWeight="{TemplateBinding FontWeight}" to have the top-level FontWeight as set on a DatePicker be used by various parts within.

Text properties on Control also inherit implicitly for a control that has a ContentPresenter within it that displays text. For example, if you set FontSize on a Button, there's no explicit {TemplateBinding} markup extension in its template or ContentPresenter part that controls what the template does with a top-level FontSize value. But the Control.FontSize value is implicitly inherited by ContentPresenter.FontSize based on the context within the template's definition, so the text within the Button will be presented using the Control.FontSize you set.

Control derived classes

Control is the parent class for these immediately derived control classes. Some of these are practical controls. Others are intermediate base classes for various controls that share characteristics.

Constructors

Control() Control() Control()

Provides base class initialization behavior for Control derived classes.

protected : Control()
protected Control()
Protected Sub New()

Properties

AccessKey AccessKey AccessKey

Inherited from UIElement

AccessKeyProperty AccessKeyProperty AccessKeyProperty

Inherited from UIElement

AccessKeyScopeOwner AccessKeyScopeOwner AccessKeyScopeOwner

Inherited from UIElement

AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty

Inherited from UIElement

ActualHeight ActualHeight ActualHeight

Inherited from FrameworkElement

ActualHeightProperty ActualHeightProperty ActualHeightProperty

Inherited from FrameworkElement

ActualTheme ActualTheme ActualTheme

Inherited from FrameworkElement

ActualThemeProperty ActualThemeProperty ActualThemeProperty

Inherited from FrameworkElement

ActualWidth ActualWidth ActualWidth

Inherited from FrameworkElement

ActualWidthProperty ActualWidthProperty ActualWidthProperty

Inherited from FrameworkElement

AllowDrop AllowDrop AllowDrop

Inherited from UIElement

AllowDropProperty AllowDropProperty AllowDropProperty

Inherited from UIElement

AllowFocusOnInteraction AllowFocusOnInteraction AllowFocusOnInteraction

Inherited from FrameworkElement

AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty

Inherited from FrameworkElement

AllowFocusWhenDisabled AllowFocusWhenDisabled AllowFocusWhenDisabled

Inherited from FrameworkElement

AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty AllowFocusWhenDisabledProperty

Inherited from FrameworkElement

Background Background Background

Gets or sets a brush that provides the background of the control.

public : Brush Background { get; set; }
public Brush Background { get; set; }
Public ReadWrite Property Background As Brush
<control Background="{StaticResource resourceName}"/>

Value
Brush Brush Brush

The brush that provides the background of the control. The default is null, (a null brush) which is evaluated as Transparent for rendering.

Remarks

Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the Background property as an input for the template's UI properties. On other controls, this property has no effect. Typically, a control uses a {TemplateBinding} markup extension to bind its Background value to the Background of a Panel that is the root element of the control template; for example, to Grid.Background. For more info about visual templates and control templating, see Styling controls or the reference page for the Template property.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background, Foreground, and BorderBrush. For more info, see the Light-weight styling section of the Styling controls article.

See Also

BackgroundProperty BackgroundProperty BackgroundProperty

Identifies the Background dependency property.

public : static DependencyProperty BackgroundProperty { get; }
public static DependencyProperty BackgroundProperty { get; }
Public Static ReadOnly Property BackgroundProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Background dependency property.

BaseUri BaseUri BaseUri

Inherited from FrameworkElement

BorderBrush BorderBrush BorderBrush

Gets or sets a brush that describes the border fill of a control.

public : Brush BorderBrush { get; set; }
public Brush BorderBrush { get; set; }
Public ReadWrite Property BorderBrush As Brush
<control Background="{StaticResource resourceName}"/>

Value
Brush Brush Brush

The brush that is used to fill the control's border. The default is null, (a null brush) which is evaluated as Transparent for rendering.

Remarks

Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the BorderBrush property as an input for the template's UI properties. On other controls, this property has no effect. Typically, if it wants to display a border, a control uses a {TemplateBinding} markup extension to bind its BorderBrush value to the BorderBrush of a Border that is the root element of the control template. For more info about visual templates and control templating, see Styling controls or the reference page for the Template property.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background, Foreground, and BorderBrush. For more info, see the Light-weight styling section of the Styling controls article.

The BorderThickness value must be greater than 0 in order to see the BorderBrush value take effect.

See Also

BorderBrushProperty BorderBrushProperty BorderBrushProperty

Identifies the BorderBrush dependency property.

public : static DependencyProperty BorderBrushProperty { get; }
public static DependencyProperty BorderBrushProperty { get; }
Public Static ReadOnly Property BorderBrushProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the BorderBrush dependency property.

BorderThickness BorderThickness BorderThickness

Gets or sets the border thickness of a control.

public : Thickness BorderThickness { get; set; }
public Thickness BorderThickness { get; set; }
Public ReadWrite Property BorderThickness As Thickness
<control BorderThickness="uniform"/>
- or -
<control BorderThickness="left&right,top&bottom"/>
- or -
<control BorderThickness="left,top,right,bottom"/>
Value
Thickness Thickness Thickness

The border thickness of a control, as a Thickness value.

Remarks

Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the BorderThickness property as a parameter. On other controls, this property has no effect. For more info about visual templates, see the Template property.

See Also

BorderThicknessProperty BorderThicknessProperty BorderThicknessProperty

Identifies the BorderThickness dependency property.

public : static DependencyProperty BorderThicknessProperty { get; }
public static DependencyProperty BorderThicknessProperty { get; }
Public Static ReadOnly Property BorderThicknessProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the BorderThickness dependency property.

CacheMode CacheMode CacheMode

Inherited from UIElement

CacheModeProperty CacheModeProperty CacheModeProperty

Inherited from UIElement

CanDrag CanDrag CanDrag

Inherited from UIElement

CanDragProperty CanDragProperty CanDragProperty

Inherited from UIElement

CharacterReceivedEvent CharacterReceivedEvent CharacterReceivedEvent

Inherited from UIElement

CharacterSpacing CharacterSpacing CharacterSpacing

Gets or sets the uniform spacing between characters, in units of 1/1000 of an em.

public : int CharacterSpacing { get; set; }
public int CharacterSpacing { get; set; }
Public ReadWrite Property CharacterSpacing As int
<control CharacterSpacing="int"/>
Value
int int int

The uniform spacing between characters, in units of 1/1000 of an em. The default is 0. Positive values increase tracking and loosen character spacing. Negative values decrease tracking and tighten the character spacing.

CharacterSpacingProperty CharacterSpacingProperty CharacterSpacingProperty

Identifies the CharacterSpacing dependency property.

public : static DependencyProperty CharacterSpacingProperty { get; }
public static DependencyProperty CharacterSpacingProperty { get; }
Public Static ReadOnly Property CharacterSpacingProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the CharacterSpacing dependency property.

Clip Clip Clip

Inherited from UIElement

ClipProperty ClipProperty ClipProperty

Inherited from UIElement

CompositeMode CompositeMode CompositeMode

Inherited from UIElement

CompositeModeProperty CompositeModeProperty CompositeModeProperty

Inherited from UIElement

ContextFlyout ContextFlyout ContextFlyout

Inherited from UIElement

ContextFlyoutProperty ContextFlyoutProperty ContextFlyoutProperty

Inherited from UIElement

DataContext DataContext DataContext

Inherited from FrameworkElement

DataContextProperty DataContextProperty DataContextProperty

Inherited from FrameworkElement

DefaultStyleKey DefaultStyleKey DefaultStyleKey

Gets or sets the key that references the default style for the control. Authors of custom controls use this property to change the default for the style that their control uses.

protected : Platform::Object DefaultStyleKey { get; set; }
protected object DefaultStyleKey { get; set; }
Protected ReadWrite Property DefaultStyleKey As object
Value
Platform::Object object object

The key that references the default style for the control. To work correctly as part of theme style lookup, this value is expected to be a System.Type value.

Note

Visual C++ component extensions (C++/CX) uses a string that is the qualified name of the type. But this relies on generated code that produces a TypeName once accessed by a XAML compiler; see Remarks.

Remarks

DefaultStyleKey is one of the very few protected properties in the Windows Runtime API. It's intended only for use by control authors, who will be subclassing some existing control class and therefore have the necessary access to set this property. For many custom control scenarios where you'll be setting DefaultStyleKey, you'll also be overriding OnApplyTemplate.

The return type of DefaultStyleKey is loosely typed as Object in the syntax, but the XAML style system will expect the value to provide a type reference:

  • For a control that has its logic written in C#, the value of DefaultStyleKey should be an instance of System.Type. Typically you set this value in the default constructor:
```csharp

public CustomControl1()

{

    this.DefaultStyleKey = typeof(CustomControl1);

}

```
  • For a control that has its logic written in Microsoft Visual Basic, the value of DefaultStyleKey should be an instance of System.Type. Typically you set this value in the default constructor:
```vbnet

Public Sub New()

    Me.DefaultStyleKey = GetType(CustomControl1)

End Sub

```
  • For a control that has its logic written in Visual C++ component extensions (C++/CX), the value of DefaultStyleKey should be a namespace-qualified string that is the name of the custom control class. Typically you set this value in the default constructor:
```cpp

CustomControl1::CustomControl1() //public: in the header

{

    DefaultStyleKey = "App1.CustomControl1";

}

```

Note

Ultimately the string alone isn't enough to support a Visual C++ component extensions (C++/CX) type reference. If you use the Add / New Item / Templated Control options in Solution Explorer, the templates and support for Visual C++ component extensions (C++/CX) and XAML generates classes that give IXamlMetadataProvider info. The XAML compiler can access this code when the XAML is loaded, and uses it to validate and create types and members and join the partial classes. As far as what you define in your own app code, the string is all you need. But if you're curious you can have a look at the XamlTypeInfo.g.h and XamlTypeInfo.g.cpp files that are generated.

Control authors could choose to not provide a value for DefaultStyleKey, but that's uncommon. The result would be that the default style is the one as defined by the base class. In some cases (like for ContentControl ) the value is null. Even if you choose to not redefine the value, make sure that the original default style is useful for rendering your control.

When a XAML control is loaded, the rendering process starts, and the system is looking for the correct template to apply, what's being loaded is the XAML default style for the control, including its template. Included in the Windows Runtime is an internal copy of all the default styles for all the XAML controls that the Windows Runtime defines. The type reference in DefaultStyleKey tells the system which named XAML resource to load as this style. In XAML form, the styles really are keyed by type even though there's no mechanism in Windows Runtime XAML that defines a type reference explicitly. But for any TargetType value, which is the attribute that holds the key for lookup, it's implicitly assumed to represent a type reference in the form of a string. For example, DefaultStyleKey from a Button is a System.Type instance where the Name is "Button", FullName is "Windows.UI.Xaml.Controls.Button". The system uses this info to know to load the Style from the internal resources that has TargetType="Button".

Custom controls usually aren't in the default XAML namespace. Instead, they're in a XAML namespace that has a using: statement to reference the app's code namespace. By default, projects create a prefix "local:" that maps this namespace for you. You could also map other XAML namespaces to refer to additional code namespaces for controls or other code that your app defines.

The "local:" prefix (or some other namespace that maps to your app's code and namespaces) should precede the name of your custom control, when it's in XAML as the TargetType value. This is also already done for you by the starting templates; when you add a new control, you'll see a generic.xaml file that contains just one style. That style will have TargetType value that is a string starting with "local:" and completed by the name you chose for your custom control class. To match previous examples that set DefaultStyleKey in a CustomControl1 definition, you'd see an element for <Style TargetType="local:CustomControl1"> defined in the starting generic.xaml, and that style defines the control template as well as setting other properties.

Note

The "local:" prefix is isolated to the XAML where it's defined and used. XAML namespaces and the prefixes only have meaning within XAML and are self-contained to each XAML file. DefaultStyleKey values in code don't include the prefixes.

See Also

DefaultStyleKeyProperty DefaultStyleKeyProperty DefaultStyleKeyProperty

Identifies the DefaultStyleKey dependency property.

public : static DependencyProperty DefaultStyleKeyProperty { get; }
public static DependencyProperty DefaultStyleKeyProperty { get; }
Public Static ReadOnly Property DefaultStyleKeyProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the DefaultStyleKey dependency property.

DefaultStyleResourceUri DefaultStyleResourceUri DefaultStyleResourceUri

Gets or sets the path to the resource file that contains the default style for the control.

public : Uri DefaultStyleResourceUri { get; set; }
public Uri DefaultStyleResourceUri { get; set; }
Public ReadWrite Property DefaultStyleResourceUri As Uri
Value
Uri Uri Uri

The path to the resource file that contains the default style for the control.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)
See Also

DefaultStyleResourceUriProperty DefaultStyleResourceUriProperty DefaultStyleResourceUriProperty

Identifies the DefaultStyleResourceUri dependency property.

public : static DependencyProperty DefaultStyleResourceUriProperty { get; }
public static DependencyProperty DefaultStyleResourceUriProperty { get; }
Public Static ReadOnly Property DefaultStyleResourceUriProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the DefaultStyleResourceUri dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

DesiredSize DesiredSize DesiredSize

Inherited from UIElement

Dispatcher Dispatcher Dispatcher

Inherited from DependencyObject

DoubleTappedEvent DoubleTappedEvent DoubleTappedEvent

Inherited from UIElement

DragEnterEvent DragEnterEvent DragEnterEvent

Inherited from UIElement

DragLeaveEvent DragLeaveEvent DragLeaveEvent

Inherited from UIElement

DragOverEvent DragOverEvent DragOverEvent

Inherited from UIElement

DropEvent DropEvent DropEvent

Inherited from UIElement

ElementSoundMode ElementSoundMode ElementSoundMode

Get or sets a value that specifies a control's preference for whether sounds are played.

public : ElementSoundMode ElementSoundMode { get; set; }
public ElementSoundMode ElementSoundMode { get; set; }
Public ReadWrite Property ElementSoundMode As ElementSoundMode
<control ElementSoundMode="elementSoundModeMemberName"/>
Value
ElementSoundMode ElementSoundMode ElementSoundMode

A value of the enumeration that specifies a control's preference for whether sounds are played. The default is Auto.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

Set the ElementSoundMode property to override the global ElementSoundPlayer setting for a specific control.

For more info about using this property, see Sound in UWP apps.

Version compatibility

The ElementSoundMode property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.

 private void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "ElementSoundMode"))
    {
        button1.ElementSoundMode = ElementSoundMode.Off;
    }
}
See Also

ElementSoundModeProperty ElementSoundModeProperty ElementSoundModeProperty

Identifies the ElementSoundMode dependency property.

public : static DependencyProperty ElementSoundModeProperty { get; }
public static DependencyProperty ElementSoundModeProperty { get; }
Public Static ReadOnly Property ElementSoundModeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the ElementSoundMode dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked

Inherited from UIElement

ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty

Inherited from UIElement

FlowDirection FlowDirection FlowDirection

Inherited from FrameworkElement

FlowDirectionProperty FlowDirectionProperty FlowDirectionProperty

Inherited from FrameworkElement

FocusState FocusState FocusState

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

public : FocusState FocusState { get; }
public FocusState FocusState { get; }
Public ReadOnly Property FocusState As FocusState
Value
FocusState FocusState 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.

Note

In Windows 8, when FocusState is Programmatic, the keyboard focus visual is shown even if the prior method of input was pointer. In Windows 8.1, when you call Focus (FocusState.Programmatic), the prior FocusState, either Pointer or Keyboard, is retained so that the correct focus visual is shown. This means that if you check the value of the FocusState property after you call Focus (FocusState.Programmatic), the FocusState property will have a value of either Pointer or Keyboard.

In an app that’s compiled for Windows 8, but run in Windows 8.1, the Windows 8 behavior is retained. The FocusState property value is Programmatic and the keyboard focus visual is shown.

Note

Classes that inherit from ItemsControl, such as ListBox and AutoSuggestBox, do not propagate the FocusState property. They will always return Unfocused. Access the correct value through RoutedEventArgs.OriginalSource.

FocusStateProperty FocusStateProperty FocusStateProperty

Identifies the FocusState dependency property.

public : static DependencyProperty FocusStateProperty { get; }
public static DependencyProperty FocusStateProperty { get; }
Public Static ReadOnly Property FocusStateProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FocusState dependency property.

FocusVisualMargin FocusVisualMargin FocusVisualMargin

Inherited from FrameworkElement

FocusVisualMarginProperty FocusVisualMarginProperty FocusVisualMarginProperty

Inherited from FrameworkElement

FocusVisualPrimaryBrush FocusVisualPrimaryBrush FocusVisualPrimaryBrush

Inherited from FrameworkElement

FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty FocusVisualPrimaryBrushProperty

Inherited from FrameworkElement

FocusVisualPrimaryThickness FocusVisualPrimaryThickness FocusVisualPrimaryThickness

Inherited from FrameworkElement

FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty FocusVisualPrimaryThicknessProperty

Inherited from FrameworkElement

FocusVisualSecondaryBrush FocusVisualSecondaryBrush FocusVisualSecondaryBrush

Inherited from FrameworkElement

FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty FocusVisualSecondaryBrushProperty

Inherited from FrameworkElement

FocusVisualSecondaryThickness FocusVisualSecondaryThickness FocusVisualSecondaryThickness

Inherited from FrameworkElement

FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty FocusVisualSecondaryThicknessProperty

Inherited from FrameworkElement

FontFamily FontFamily FontFamily

Gets or sets the font used to display text in the control.

public : FontFamily FontFamily { get; set; }
public FontFamily FontFamily { get; set; }
Public ReadWrite Property FontFamily As FontFamily
<control FontFamily="fontFamilyValue"/>
Value
FontFamily FontFamily FontFamily

The font used to display text in the control.

FontFamilyProperty FontFamilyProperty FontFamilyProperty

Identifies the FontFamily dependency property.

public : static DependencyProperty FontFamilyProperty { get; }
public static DependencyProperty FontFamilyProperty { get; }
Public Static ReadOnly Property FontFamilyProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontFamily dependency property.

FontSize FontSize FontSize

Gets or sets the size of the text in this control.

public : double FontSize { get; set; }
public double FontSize { get; set; }
Public ReadWrite Property FontSize As double
<control FontSize="double"/>
Value
double double double

The size of the text in the Control, in pixels.

Remarks

The unit measure for FontSize is pixels, measuring the line height of the characters in the font. The apparent size of text in the UI can vary based on the current scaling. If you want to use different FontSize values for different scalings, you can do this using the resources system.

The default value of FontSize is 11.

See Also

FontSizeProperty FontSizeProperty FontSizeProperty

Identifies the FontSize dependency property.

public : static DependencyProperty FontSizeProperty { get; }
public static DependencyProperty FontSizeProperty { get; }
Public Static ReadOnly Property FontSizeProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontSize dependency property.

FontStretch FontStretch FontStretch

Gets or sets the degree to which a font is condensed or expanded on the screen.

public : FontStretch FontStretch { get; set; }
public FontStretch FontStretch { get; set; }
Public ReadWrite Property FontStretch As FontStretch
<control FontStretch="fontStretchMemberName"/>
Value
FontStretch FontStretch FontStretch

One of the values that specifies the degree to which a font is condensed or expanded on the screen. The default is Normal.

FontStretchProperty FontStretchProperty FontStretchProperty

Identifies the FontStretch dependency property.

public : static DependencyProperty FontStretchProperty { get; }
public static DependencyProperty FontStretchProperty { get; }
Public Static ReadOnly Property FontStretchProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontStretch dependency property.

FontStyle FontStyle FontStyle

Gets or sets the style in which the text is rendered.

public : FontStyle FontStyle { get; set; }
public FontStyle FontStyle { get; set; }
Public ReadWrite Property FontStyle As FontStyle
<control FontStyle="fontStyleMemberName" />
Value
FontStyle FontStyle FontStyle

One of the values that specifies the style in which the text is rendered. The default is Normal.

FontStyleProperty FontStyleProperty FontStyleProperty

Identifies the FontStyle dependency property.

public : static DependencyProperty FontStyleProperty { get; }
public static DependencyProperty FontStyleProperty { get; }
Public Static ReadOnly Property FontStyleProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontStyle dependency property.

FontWeight FontWeight FontWeight

Gets or sets the thickness of the specified font.

public : FontWeight FontWeight { get; set; }
public FontWeight FontWeight { get; set; }
Public ReadWrite Property FontWeight As FontWeight
<control FontWeight="fontWeightMemberName"/>
Value
FontWeight FontWeight FontWeight

One of the values that specifies the thickness of the specified font. The default is Normal.

FontWeightProperty FontWeightProperty FontWeightProperty

Identifies the FontWeight dependency property.

public : static DependencyProperty FontWeightProperty { get; }
public static DependencyProperty FontWeightProperty { get; }
Public Static ReadOnly Property FontWeightProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the FontWeight dependency property.

Foreground Foreground Foreground

Gets or sets a brush that describes the foreground color.

public : Brush Foreground { get; set; }
public Brush Foreground { get; set; }
Public ReadWrite Property Foreground As Brush
<control Foreground="{StaticResource resourceName}"/>

Value
Brush Brush Brush

The brush that paints the foreground of the control. The default value is a SolidColorBrush with color of Black.

Remarks

Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the Foreground property as a parameter. On other controls, this property has no effect. Typically, a ContentControl derived control uses a {TemplateBinding} markup extension to bind its Foreground value to the Foreground of a ContentPresenter within the control template. The same color/brush might also be used for values of other decorative elements in the template (glyphs, icons, control surfaces) or to composite part properties such as the individual ComboBox elements of the TimePicker control. For more info about visual templates and control templating, see Styling controls or the reference page for the Template property.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background, Foreground, and BorderBrush. For more info, see the Light-weight styling section of the Styling controls article.

See Also

ForegroundProperty ForegroundProperty ForegroundProperty

Identifies the Foreground dependency property.

public : static DependencyProperty ForegroundProperty { get; }
public static DependencyProperty ForegroundProperty { get; }
Public Static ReadOnly Property ForegroundProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Foreground dependency property.

GettingFocusEvent GettingFocusEvent GettingFocusEvent

Inherited from UIElement

Height Height Height

Inherited from FrameworkElement

HeightProperty HeightProperty HeightProperty

Inherited from FrameworkElement

HighContrastAdjustment HighContrastAdjustment HighContrastAdjustment

Inherited from UIElement

HighContrastAdjustmentProperty HighContrastAdjustmentProperty HighContrastAdjustmentProperty

Inherited from UIElement

HoldingEvent HoldingEvent HoldingEvent

Inherited from UIElement

HorizontalAlignment HorizontalAlignment HorizontalAlignment

Inherited from FrameworkElement

HorizontalAlignmentProperty HorizontalAlignmentProperty HorizontalAlignmentProperty

Inherited from FrameworkElement

HorizontalContentAlignment HorizontalContentAlignment HorizontalContentAlignment

Gets or sets the horizontal alignment of the control's content.

public : HorizontalAlignment HorizontalContentAlignment { get; set; }
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Public ReadWrite Property HorizontalContentAlignment As HorizontalAlignment
<control HorizontalContentAlignment="horizontalAlignmentMemberName"/>
Value
HorizontalAlignment HorizontalAlignment HorizontalAlignment

One of the HorizontalAlignment values. The default is Left.

Remarks

Each control might apply this property differently based on the Style setters for the control's implicit style, and its visual template. Also, the apparent "default value" of each individual control used in UI can be different. For example, a Button control starts with the value Center.

A value for the HorizontalContentAlignment property only affects layout behavior for a control when its template uses the HorizontalContentAlignment property as the source of a HorizontalAlignment value for presenters or content areas within. On other controls, setting HorizontalContentAlignment has no effect. For more info about visual templates for controls, see the reference for Control.Template.

See Also

HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty HorizontalContentAlignmentProperty

Identifies the HorizontalContentAlignment dependency property.

public : static DependencyProperty HorizontalContentAlignmentProperty { get; }
public static DependencyProperty HorizontalContentAlignmentProperty { get; }
Public Static ReadOnly Property HorizontalContentAlignmentProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the HorizontalContentAlignment dependency property.

IsAccessKeyScope IsAccessKeyScope IsAccessKeyScope

Inherited from UIElement

IsAccessKeyScopeProperty IsAccessKeyScopeProperty IsAccessKeyScopeProperty

Inherited from UIElement

IsDoubleTapEnabled IsDoubleTapEnabled IsDoubleTapEnabled

Inherited from UIElement

IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty IsDoubleTapEnabledProperty

Inherited from UIElement

IsEnabled IsEnabled IsEnabled

Gets or sets a value indicating whether the user can interact with the control.

public : Platform::Boolean IsEnabled { get; set; }
public bool IsEnabled { get; set; }
Public ReadWrite Property IsEnabled As bool
<control IsEnabled="bool"/>
Value
Platform::Boolean bool bool

true if the user can interact with the control; otherwise, false.

Remarks

Many controls have predefined visual states that are invoked for IsEnabled =false, such as "graying out" text in labels.

Whenever IsEnabled changes, that fires the IsEnabledChanged event. Controls might handle this event in order to change the visual states. The event has DependencyPropertyChangedEventArgs data, so you can determine the old and new values without having to use your own flags.

A control inherits the IsEnabled property from its parent control. For example, if a control that contains a button has IsEnabled set to false, the button's IsEnabled property is also false. When the parent's property changes, that fires IsEnabledChanged for each control where the value changes because of the value inheriting.

How the control logic behaves when disabled is potentially different for each control. However, these behaviors will result in all controls when IsEnabled =false:

  • The control can't receive keyboard focus or be focused programmatically.
  • The control does not appear in a tab sequence (any value for TabIndex is ignored).
  • A disabled control is still visible to hit testing. It can't handle any input events on itself. However, a disabled control can still source the input events, and input routed events can bubble to a parent where they can be handled.
See Also

IsEnabledProperty IsEnabledProperty IsEnabledProperty

Identifies the IsEnabled dependency property.

public : static DependencyProperty IsEnabledProperty { get; }
public static DependencyProperty IsEnabledProperty { get; }
Public Static ReadOnly Property IsEnabledProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the IsEnabled dependency property.

IsFocusEngaged IsFocusEngaged IsFocusEngaged

Get or sets a value that indicates whether focus is constrained within the control boundaries (for game pad/remote interaction).

public : Platform::Boolean IsFocusEngaged { get; set; }
public bool IsFocusEngaged { get; set; }
Public ReadWrite Property IsFocusEngaged As bool
<control IsFocusEngaged="bool"/>
Value
Platform::Boolean bool bool

true if focus is constrained within the control boundaries; otherwise, false.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

IsFocusEngagementEnabled must be true and the control must have focus before you set the IsFocusEngaged property to true. Otherwise, a runtime exception will occur.

Focus engagement makes it easier to use a game pad or remote control to interact with an app. Setting focus engagement does not affect keyboard or other input devices.

When the IsFocusEngagementEnabled property is set to true, it marks the control as requiring focus engagement. This means that the user must press the A/Select button to "engage" the control and interact with it. When they are finished, they can press the B/Back button to disengage the control and navigate away from it.

For more info about this property, see the Focus engagement section of the Designing for Xbox and TV article.

Version compatibility

The IsFocusEngaged property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "IsFocusEngaged"))
{
    slider1.IsFocusEngaged = true;
}

IsFocusEngagedProperty IsFocusEngagedProperty IsFocusEngagedProperty

Identifies the IsFocusEngaged dependency property.

public : static DependencyProperty IsFocusEngagedProperty { get; }
public static DependencyProperty IsFocusEngagedProperty { get; }
Public Static ReadOnly Property IsFocusEngagedProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the IsFocusEngaged dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

IsFocusEngagementEnabled IsFocusEngagementEnabled IsFocusEngagementEnabled

Get or sets a value that indicates whether focus can be constrained within the control boundaries (for game pad/remote interaction).

public : Platform::Boolean IsFocusEngagementEnabled { get; set; }
public bool IsFocusEngagementEnabled { get; set; }
Public ReadWrite Property IsFocusEngagementEnabled As bool
<control IsFocusEngagementEnabled="bool"/>
Value
Platform::Boolean bool bool

true if focus can be constrained within the control boundaries; otherwise, false.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

Focus engagement makes it easier to use a game pad or remote control to interact with an app. Setting focus engagement does not affect keyboard or other input devices.

When the IsFocusEngagementEnabled property is set to true, it marks the control as requiring focus engagement. This means that the user must press the A/Select button to "engage" the control and interact with it. When they are finished, they can press the B/Back button to disengage the control and navigate away from it.

For more info about this property, see the Focus engagement section of the Designing for Xbox and TV article.

Version compatibility

The IsFocusEngagementEnabled property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "IsFocusEngagementEnabled"))
{
    slider1.IsFocusEngagementEnabled = true;
}

IsFocusEngagementEnabledProperty IsFocusEngagementEnabledProperty IsFocusEngagementEnabledProperty

Identifies the IsFocusEngagementEnabled dependency property.

public : static DependencyProperty IsFocusEngagementEnabledProperty { get; }
public static DependencyProperty IsFocusEngagementEnabledProperty { get; }
Public Static ReadOnly Property IsFocusEngagementEnabledProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the IsFocusEngagementEnabled dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

IsHitTestVisible IsHitTestVisible IsHitTestVisible

Inherited from UIElement

IsHitTestVisibleProperty IsHitTestVisibleProperty IsHitTestVisibleProperty

Inherited from UIElement

IsHoldingEnabled IsHoldingEnabled IsHoldingEnabled

Inherited from UIElement

IsHoldingEnabledProperty IsHoldingEnabledProperty IsHoldingEnabledProperty

Inherited from UIElement

IsRightTapEnabled IsRightTapEnabled IsRightTapEnabled

Inherited from UIElement

IsRightTapEnabledProperty IsRightTapEnabledProperty IsRightTapEnabledProperty

Inherited from UIElement

IsTabStop IsTabStop IsTabStop

Gets or sets a value that indicates whether a control is included in tab navigation.

public : Platform::Boolean IsTabStop { get; set; }
public bool IsTabStop { get; set; }
Public ReadWrite Property IsTabStop As bool
<control IsTabStop="bool"/>
Value
Platform::Boolean bool bool

true if the control is included in tab navigation; otherwise, false. The default is true.

Remarks

Controlling the tab sequence with a combination of IsTabStop and TabIndex rather than using the default tab sequence is sometimes necessary in order to tune the keyboard accessibility of your UI. For more info, see Keyboard accessibility.

If IsTabStop is false, the control is excluded from tab navigation. In addition, if IsTabStop is false, the control cannot receive input focus. (If you try to set focus programmatically, by calling the Focus method, Focus returns false).

If the reason you don't want the control to be a tab stop is because it's not interactive in your UI, you might want to set IsEnabled to false to make the lack of interaction more obvious. Many controls have predefined visual states that are invoked for IsEnabled =false, such as "graying out" text in labels.

See Also

IsTabStopProperty IsTabStopProperty IsTabStopProperty

Identifies the IsTabStop dependency property.

public : static DependencyProperty IsTabStopProperty { get; }
public static DependencyProperty IsTabStopProperty { get; }
Public Static ReadOnly Property IsTabStopProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the IsTabStop dependency property.

IsTapEnabled IsTapEnabled IsTapEnabled

Inherited from UIElement

IsTapEnabledProperty IsTapEnabledProperty IsTapEnabledProperty

Inherited from UIElement

IsTemplateFocusTargetProperty IsTemplateFocusTargetProperty IsTemplateFocusTargetProperty

Identifies the Control.IsTemplateFocusTarget XAML attached property.

public : static DependencyProperty IsTemplateFocusTargetProperty { get; }
public static DependencyProperty IsTemplateFocusTargetProperty { get; }
Public Static ReadOnly Property IsTemplateFocusTargetProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Control.IsTemplateFocusTarget XAML attached property.

See Also

IsTemplateKeyTipTargetProperty IsTemplateKeyTipTargetProperty IsTemplateKeyTipTargetProperty

Identifies the Control.IsTemplateKeyTipTarget XAML attached property.

public : static DependencyProperty IsTemplateKeyTipTargetProperty { get; }
public static DependencyProperty IsTemplateKeyTipTargetProperty { get; }
Public Static ReadOnly Property IsTemplateKeyTipTargetProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Control.IsTemplateKeyTipTarget XAML attached property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

IsTextScaleFactorEnabled IsTextScaleFactorEnabled IsTextScaleFactorEnabled

Gets or sets whether automatic text enlargement, to reflect the system text size setting, is enabled.

public : Platform::Boolean IsTextScaleFactorEnabled { get; set; }
public bool IsTextScaleFactorEnabled { get; set; }
Public ReadWrite Property IsTextScaleFactorEnabled As bool
<control IsTextScaleFactorEnabled="bool"/>
Value
Platform::Boolean bool bool

true if automatic text enlargement is enabled; otherwise, false.

See Also

IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty

Identifies the IsTextScaleFactorEnabled dependency property.

public : static DependencyProperty IsTextScaleFactorEnabledProperty { get; }
public static DependencyProperty IsTextScaleFactorEnabledProperty { get; }
Public Static ReadOnly Property IsTextScaleFactorEnabledProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the IsTextScaleFactorEnabled dependency property.

KeyDownEvent KeyDownEvent KeyDownEvent

Inherited from UIElement

KeyTipHorizontalOffset KeyTipHorizontalOffset KeyTipHorizontalOffset

Inherited from UIElement

KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty

Inherited from UIElement

KeyTipPlacementMode KeyTipPlacementMode KeyTipPlacementMode

Inherited from UIElement

KeyTipPlacementModeProperty KeyTipPlacementModeProperty KeyTipPlacementModeProperty

Inherited from UIElement

KeyTipVerticalOffset KeyTipVerticalOffset KeyTipVerticalOffset

Inherited from UIElement

KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty

Inherited from UIElement

KeyUpEvent KeyUpEvent KeyUpEvent

Inherited from UIElement

KeyboardAccelerators KeyboardAccelerators KeyboardAccelerators

Inherited from UIElement

Language Language Language

Inherited from FrameworkElement

LanguageProperty LanguageProperty LanguageProperty

Inherited from FrameworkElement

Lights Lights Lights

Inherited from UIElement

LightsProperty LightsProperty LightsProperty

Inherited from UIElement

LosingFocusEvent LosingFocusEvent LosingFocusEvent

Inherited from UIElement

ManipulationCompletedEvent ManipulationCompletedEvent ManipulationCompletedEvent

Inherited from UIElement

ManipulationDeltaEvent ManipulationDeltaEvent ManipulationDeltaEvent

Inherited from UIElement

ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent ManipulationInertiaStartingEvent

Inherited from UIElement

ManipulationMode ManipulationMode ManipulationMode

Inherited from UIElement

ManipulationModeProperty ManipulationModeProperty ManipulationModeProperty

Inherited from UIElement

ManipulationStartedEvent ManipulationStartedEvent ManipulationStartedEvent

Inherited from UIElement

ManipulationStartingEvent ManipulationStartingEvent ManipulationStartingEvent

Inherited from UIElement

Margin Margin Margin

Inherited from FrameworkElement

MarginProperty MarginProperty MarginProperty

Inherited from FrameworkElement

MaxHeight MaxHeight MaxHeight

Inherited from FrameworkElement

MaxHeightProperty MaxHeightProperty MaxHeightProperty

Inherited from FrameworkElement

MaxWidth MaxWidth MaxWidth

Inherited from FrameworkElement

MaxWidthProperty MaxWidthProperty MaxWidthProperty

Inherited from FrameworkElement

MinHeight MinHeight MinHeight

Inherited from FrameworkElement

MinHeightProperty MinHeightProperty MinHeightProperty

Inherited from FrameworkElement

MinWidth MinWidth MinWidth

Inherited from FrameworkElement

MinWidthProperty MinWidthProperty MinWidthProperty

Inherited from FrameworkElement

Name Name Name

Inherited from FrameworkElement

NameProperty NameProperty NameProperty

Inherited from FrameworkElement

NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent NoFocusCandidateFoundEvent

Inherited from UIElement

Opacity Opacity Opacity

Inherited from UIElement

OpacityProperty OpacityProperty OpacityProperty

Inherited from UIElement

Padding Padding Padding

Gets or sets the padding inside a control.

public : Thickness Padding { get; set; }
public Thickness Padding { get; set; }
Public ReadWrite Property Padding As Thickness
<control Padding="uniform"/>
- or -
<control Padding="left&right,top&bottom"/>
- or -
<control Padding="left,top,right,bottom"/>
Value
Thickness Thickness Thickness

The amount of space between the content of a Control and its Margin or Border. The default is a Thickness with values of 0 on all four sides.

Remarks

Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the Padding property as a parameter. On other controls, this property has no effect. For more info about control templates, see the Template property.

A related property is Margin (a property of FrameworkElement ). For many controls, margin and padding would typically blend together with the division between them not being apparent in the rendering. For such controls it's typical to specify a Margin or a Padding, but not both. For more info about the relationship between margin and padding, see Alignment, margin, and padding or Define layouts with XAML.

See Also

PaddingProperty PaddingProperty PaddingProperty

Identifies the Padding dependency property.

public : static DependencyProperty PaddingProperty { get; }
public static DependencyProperty PaddingProperty { get; }
Public Static ReadOnly Property PaddingProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Padding dependency property.

Parent Parent Parent

Inherited from FrameworkElement

PointerCanceledEvent PointerCanceledEvent PointerCanceledEvent

Inherited from UIElement

PointerCaptureLostEvent PointerCaptureLostEvent PointerCaptureLostEvent

Inherited from UIElement

PointerCaptures PointerCaptures PointerCaptures

Inherited from UIElement

PointerCapturesProperty PointerCapturesProperty PointerCapturesProperty

Inherited from UIElement

PointerEnteredEvent PointerEnteredEvent PointerEnteredEvent

Inherited from UIElement

PointerExitedEvent PointerExitedEvent PointerExitedEvent

Inherited from UIElement

PointerMovedEvent PointerMovedEvent PointerMovedEvent

Inherited from UIElement

PointerPressedEvent PointerPressedEvent PointerPressedEvent

Inherited from UIElement

PointerReleasedEvent PointerReleasedEvent PointerReleasedEvent

Inherited from UIElement

PointerWheelChangedEvent PointerWheelChangedEvent PointerWheelChangedEvent

Inherited from UIElement

PreviewKeyDownEvent PreviewKeyDownEvent PreviewKeyDownEvent

Inherited from UIElement

PreviewKeyUpEvent PreviewKeyUpEvent PreviewKeyUpEvent

Inherited from UIElement

Projection Projection Projection

Inherited from UIElement

ProjectionProperty ProjectionProperty ProjectionProperty

Inherited from UIElement

RenderSize RenderSize RenderSize

Inherited from UIElement

RenderTransform RenderTransform RenderTransform

Inherited from UIElement

RenderTransformOrigin RenderTransformOrigin RenderTransformOrigin

Inherited from UIElement

RenderTransformOriginProperty RenderTransformOriginProperty RenderTransformOriginProperty

Inherited from UIElement

RenderTransformProperty RenderTransformProperty RenderTransformProperty

Inherited from UIElement

RequestedTheme RequestedTheme RequestedTheme

Inherited from FrameworkElement

RequestedThemeProperty RequestedThemeProperty RequestedThemeProperty

Inherited from FrameworkElement

RequiresPointer RequiresPointer RequiresPointer

Gets or sets whether a UI element supports mouse mode, which emulates pointer interaction experiences with non-pointer input devices such as an Xbox gamepad or remote control.

public : RequiresPointer RequiresPointer { get; set; }
public RequiresPointer RequiresPointer { get; set; }
Public ReadWrite Property RequiresPointer As RequiresPointer
<control RequiresPointer="requiresPointerMemberName"/>
Value
RequiresPointer RequiresPointer RequiresPointer

The pointer emulation mode. The default is Never.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

For non-pointer input devices, focus is moved between controls through a variety of methods, such as the Tab and arrow keys on a keyboard, the directional pad (D-pad) on a remote, or thumb sticks on an Xbox controller. For some user experiences, such as maps and drawing surfaces, it is not possible or practical to use XY focus navigation. RequiresPointer enables an app to provide a more pointer-like interaction experience through a cursor that can be moved freely using the Xbox input devices.

RequiresPointer is supported only on the Xbox device family, and only when using a game pad or remote control. The property is ignored otherwise.

RequiresPointerMode sets mouse mode at the application level.

For more info, see the Mouse mode section of Designing for Xbox and TV.

Version compatibility

The RequiresPointer property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "RequiresPointer"))
{
    mapControl1.RequiresPointer = RequiresPointer.WhenEngaged;
}

RequiresPointerProperty RequiresPointerProperty RequiresPointerProperty

Identifies the RequiresPointer dependency property.

public : static DependencyProperty RequiresPointerProperty { get; }
public static DependencyProperty RequiresPointerProperty { get; }
Public Static ReadOnly Property RequiresPointerProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the RequiresPointer dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Resources Resources Resources

Inherited from FrameworkElement

RightTappedEvent RightTappedEvent RightTappedEvent

Inherited from UIElement

Style Style Style

Inherited from FrameworkElement

StyleProperty StyleProperty StyleProperty

Inherited from FrameworkElement

TabFocusNavigation TabFocusNavigation TabFocusNavigation

Inherited from UIElement

TabFocusNavigationProperty TabFocusNavigationProperty TabFocusNavigationProperty

Inherited from UIElement

TabIndex TabIndex TabIndex

Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key.

public : int TabIndex { get; set; }
public int TabIndex { get; set; }
Public ReadWrite Property TabIndex As int
<control TabIndex="int/>
Value
int int int

A value that determines the order of logical navigation for a device. The default value is MaxValue.

See Also

TabIndexProperty TabIndexProperty TabIndexProperty

Identifies the TabIndex dependency property.

public : static DependencyProperty TabIndexProperty { get; }
public static DependencyProperty TabIndexProperty { get; }
Public Static ReadOnly Property TabIndexProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the TabIndex dependency property.

TabNavigation TabNavigation TabNavigation

Gets or sets a value that modifies how tabbing and TabIndex work for this control.

Note

For Windows 10 Creators Update (build 10.0.15063) and newer, the TabFocusNavigation property is available on the UIElement base class to include objects in the tab sequence that do not use a ControlTemplate.

public : KeyboardNavigationMode TabNavigation { get; set; }
public KeyboardNavigationMode TabNavigation { get; set; }
Public ReadWrite Property TabNavigation As KeyboardNavigationMode
<control TabNavigation="keyboardNavigationModeMemberName"/>
Value
KeyboardNavigationMode KeyboardNavigationMode KeyboardNavigationMode

A value of the enumeration. The default is Local.

See Also

TabNavigationProperty TabNavigationProperty TabNavigationProperty

Identifies the TabNavigation dependency property.

public : static DependencyProperty TabNavigationProperty { get; }
public static DependencyProperty TabNavigationProperty { get; }
Public Static ReadOnly Property TabNavigationProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the TabNavigation dependency property.

Tag Tag Tag

Inherited from FrameworkElement

TagProperty TagProperty TagProperty

Inherited from FrameworkElement

TappedEvent TappedEvent TappedEvent

Inherited from UIElement

Template Template Template

Gets or sets a control template. The control template defines the visual appearance of a control in UI, and is defined in XAML markup.

public : ControlTemplate Template { get; set; }
public ControlTemplate Template { get; set; }
Public ReadWrite Property Template As ControlTemplate
<control Template="{StaticResource templateResourceKey}"/>
Value
ControlTemplate ControlTemplate ControlTemplate

The template that defines the appearance of the Control. The ControlTemplate must have exactly one root element as its content.

Examples

This example shows a more complete control template defined as a Style and Setter with Setter.Property value of "Template". This is a named style for a RadioButton control. It includes the template elements that are normally part of a functional control template, such as a VisualStateManager.VisualStateGroups attached property element attached to the root element of the template, and x:Name attribute values assigned to each of the prominent control parts.


    <Style x:Key="TextRadioButtonStyle" TargetType="RadioButton"> 
        <Setter Property="MinWidth" Value="0"/> 
        <Setter Property="MinHeight" Value="0"/> 
        <Setter Property="Template"> 
            <Setter.Value> 
                <ControlTemplate TargetType="RadioButton"> 
                    <Grid Background="Transparent"> 
                        <TextBlock 
                            x:Name="Text" 
                            Text="{TemplateBinding Content}" 
                            Margin="3,-7,3,10" 
                            TextWrapping="NoWrap" 
                            Style="{StaticResource SubheaderTextStyle}"/> 
                        <Rectangle 
                            x:Name="FocusVisualWhite" 
                            IsHitTestVisible="False" 
                            Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}" 
                            StrokeEndLineCap="Square" 
                            StrokeDashArray="1,1" 
                            Opacity="0" 
                            StrokeDashOffset="1.5"/> 
                        <Rectangle 
                            x:Name="FocusVisualBlack" 
                            IsHitTestVisible="False" 
                            Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}" 
                            StrokeEndLineCap="Square" 
                            StrokeDashArray="1,1" 
                            Opacity="0" 
                            StrokeDashOffset="0.5"/> 

                        <VisualStateManager.VisualStateGroups> 
                            <VisualStateGroup x:Name="CommonStates"> 
                                <VisualState x:Name="Normal"/> 
                                <VisualState x:Name="PointerOver"> 
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground"> 
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationPointerOverForegroundThemeBrush}"/> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
                                <VisualState x:Name="Pressed"> 

                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground"> 
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationPressedForegroundThemeBrush}"/> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
                                <VisualState x:Name="Disabled"> 
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground"> 
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledForegroundThemeBrush}"/> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
                            </VisualStateGroup> 
                            <VisualStateGroup x:Name="FocusStates"> 
                                <VisualState x:Name="Focused"> 
                                    <Storyboard> 
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualWhite" Storyboard.TargetProperty="Opacity"/> 
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="FocusVisualBlack" Storyboard.TargetProperty="Opacity"/> 
                                    </Storyboard> 
                                </VisualState> 
                                <VisualState x:Name="Unfocused"/> 
                            </VisualStateGroup> 
                            <VisualStateGroup x:Name="CheckStates"> 
                                <VisualState x:Name="Checked"/> 
                                <VisualState x:Name="Unchecked"> 
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Text" Storyboard.TargetProperty="Foreground"> 
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ApplicationSecondaryForegroundThemeBrush}"/> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
                                <VisualState x:Name="Indeterminate"/> 
                            </VisualStateGroup> 
                        </VisualStateManager.VisualStateGroups> 
                    </Grid> 
                </ControlTemplate> 
            </Setter.Value> 
        </Setter> 
    </Style> 

Remarks

The second XAML syntax shown above is a Setter syntax as part of a Style. This is how a Template value for a Control is defined in almost all cases.

TargetType is a required attribute on all ControlTemplate elements used as a Template value. The value should match the TargetType property for the Style that contains the Setter for Template, if you are using a style-setter syntax.

The ControlTemplate specifies the appearance of a Control; if a Control does not have a ControlTemplate, the Control will have no visible presence in your app. The control author defines the default control template, and the app author can re-template the ControlTemplate XAML to redefine the visual tree of the control.

Control templates are typically set in Extensible Application Markup Language (XAML) as part of a control-specific implicit style. In this case, a Property value in the Setter is set as the string "Template", and the Setter.Value value is set as a property element, which contains a ControlTemplate object element. For example, this is the Style that defines a Template value for a ScrollViewer. This is an example of an implicit style, where the Style can be in a ResourceDictionary but doesn't need an x:Key attribute.


<ResourceDictionary>
  <Style TargetType="ScrollViewer">
  ...
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="ScrollViewer">
          <!--visual root of template for a ScrollViewer-->
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  ...
</ResourceDictionary>

Styles and templates

You can use a Setter in a Style to apply values to any dependency property. But it's the Setter for the Template property of a Control -derived class that constitutes the majority of the XAML markup in a typical Style. When a Style is used to define a control template, the TargetType of the Style element and the TargetType of the ControlTemplate element for its Control.Template setter should always use the same value. The Template setter defines the basic templated UI definition for a control where that template is applied. It also contains the visual states for a control, and other state-based UI definitions such as default theme transitions. For a complex control such as ListBox, the default template Style and the ControlTemplate within can have hundreds of lines of XAML. For more info on the role of Template in control templating scenarios, see Quickstart: Control templates.

Implicit styles

You can define styles such that a Style is used implicitly by all objects of the same TargetType, without requiring each instance of such an object to specifically reference the Style as a FrameworkElement.Style value. When a <Style> resource is declared in a ResourceDictionary without an x:Key attribute, the x:Key value uses the value of the TargetType property. If you set the style implicitly, the style is applied only to the types that match the TargetType exactly and not to elements derived from the TargetType value. For example, if you create a style implicitly for all the ToggleButton controls in your application, and your application has ToggleButton and CheckBox controls (CheckBox derives from ToggleButton ), the "ToggleButton" implicit style is applied only to the ToggleButton controls.

See Also

TemplateProperty TemplateProperty TemplateProperty

Identifies the Template dependency property.

public : static DependencyProperty TemplateProperty { get; }
public static DependencyProperty TemplateProperty { get; }
Public Static ReadOnly Property TemplateProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Template dependency property.

Transform3D Transform3D Transform3D

Inherited from UIElement

Transform3DProperty Transform3DProperty Transform3DProperty

Inherited from UIElement

Transitions Transitions Transitions

Inherited from UIElement

TransitionsProperty TransitionsProperty TransitionsProperty

Inherited from UIElement

Triggers Triggers Triggers

Inherited from FrameworkElement

UseLayoutRounding UseLayoutRounding UseLayoutRounding

Inherited from UIElement

UseLayoutRoundingProperty UseLayoutRoundingProperty UseLayoutRoundingProperty

Inherited from UIElement

UseSystemFocusVisuals UseSystemFocusVisuals UseSystemFocusVisuals

Gets or sets a value that indicates whether the control uses focus visuals that are drawn by the system or those defined in the control template.

public : Platform::Boolean UseSystemFocusVisuals { get; set; }
public bool UseSystemFocusVisuals { get; set; }
Public ReadWrite Property UseSystemFocusVisuals As bool
Value
Platform::Boolean bool bool

true if the control uses focus visuals drawn by the system; false if the control uses focus visuals defined in the ControlTemplate. The default is false; see Remarks.

Examples

This example shows a ControlTemplate that defines custom focus visuals for a Button.

Some elements of the control template aren't shown to make the relevant parts more clear. To see the full control template for Button, see Button styles and templates.

<Style TargetType="Button">

<!-- Set UseSystemFocusVisuals to false. -->
    <Setter Property="UseSystemFocusVisuals" Value="False"/> 
     ...

    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="PointerOver">
                             ...

                            </VisualState>
                        </VisualStateGroup>

<!-- Add VisualStateGroup for FocusStates. -->
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Focused">
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
                                                     Storyboard.TargetProperty="Opacity"
                                                     To="1"
                                                     Duration="0"/>
                                    <DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
                                                     Storyboard.TargetProperty="Opacity"
                                                     To="1"
                                                     Duration="0"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Unfocused"/>
                            <VisualState x:Name="PointerFocused"/>
                        </VisualStateGroup>

                    </VisualStateManager.VisualStateGroups>
                    <Border x:Name="Border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Margin="3">
                        <ContentPresenter x:Name="ContentPresenter"
                                          Content="{TemplateBinding Content}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                          AutomationProperties.AccessibilityView="Raw"/>
                    </Border>

<!-- Add elements for focus visuals. -->
                    <Rectangle x:Name="FocusVisualWhite"
                               IsHitTestVisible="False"
                               Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}"
                               StrokeEndLineCap="Square"
                               StrokeDashArray="1,1"
                               Opacity="0"
                               StrokeDashOffset="1.5"/>
                    <Rectangle x:Name="FocusVisualBlack"
                               IsHitTestVisible="False"
                               Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}"
                               StrokeEndLineCap="Square"
                               StrokeDashArray="1,1"
                               Opacity="0"
                               StrokeDashOffset="0.5"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Remarks

This property is false by default so that a custom ControlTemplate that defines its own focus visuals works as expected. However, all XAML framework controls set this property to true in their ControlTemplate and use system drawn focus visuals.

To define custom focus visuals for a control, you need to provide a custom ControlTemplate. In the ControlTemplate, do the following:

See Also

UseSystemFocusVisualsProperty UseSystemFocusVisualsProperty UseSystemFocusVisualsProperty

Identifies the UseSystemFocusVisuals dependency property.

public : static DependencyProperty UseSystemFocusVisualsProperty { get; }
public static DependencyProperty UseSystemFocusVisualsProperty { get; }
Public Static ReadOnly Property UseSystemFocusVisualsProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the UseSystemFocusVisuals dependency property.

See Also

VerticalAlignment VerticalAlignment VerticalAlignment

Inherited from FrameworkElement

VerticalAlignmentProperty VerticalAlignmentProperty VerticalAlignmentProperty

Inherited from FrameworkElement

VerticalContentAlignment VerticalContentAlignment VerticalContentAlignment

Gets or sets the vertical alignment of the control's content.

public : VerticalAlignment VerticalContentAlignment { get; set; }
public VerticalAlignment VerticalContentAlignment { get; set; }
Public ReadWrite Property VerticalContentAlignment As VerticalAlignment
<control VerticalContentAlignment="verticalAlignmentValue"/>
Value
VerticalAlignment VerticalAlignment VerticalAlignment

One of the VerticalAlignment values. The default is Top.

Remarks

Each control might apply this property differently based on the Style setters for the control's implicit style, and its visual template. Also, the apparent "default value" of each individual control used in UI can be different. For example, a Button control starts with the value Center.

A value for the VerticalContentAlignment property only affects layout behavior for a control when its template uses the VerticalContentAlignment property as the source of a VerticalAlignment value for presenters or content areas within. On other controls, setting VerticalContentAlignment has no effect. For more info about visual templates for controls, see the reference for Control.Template.

See Also

VerticalContentAlignmentProperty VerticalContentAlignmentProperty VerticalContentAlignmentProperty

Identifies the VerticalContentAlignment dependency property.

public : static DependencyProperty VerticalContentAlignmentProperty { get; }
public static DependencyProperty VerticalContentAlignmentProperty { get; }
Public Static ReadOnly Property VerticalContentAlignmentProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the VerticalContentAlignment dependency property.

Visibility Visibility Visibility

Inherited from UIElement

VisibilityProperty VisibilityProperty VisibilityProperty

Inherited from UIElement

Width Width Width

Inherited from FrameworkElement

WidthProperty WidthProperty WidthProperty

Inherited from FrameworkElement

XYFocusDown XYFocusDown XYFocusDown

Gets or sets the object that gets focus when a user presses the Directional Pad (D-pad) down.

public : DependencyObject XYFocusDown { get; set; }
public DependencyObject XYFocusDown { get; set; }
Public ReadWrite Property XYFocusDown As DependencyObject
<control XYFocusDown="{x:Bind dependencyObjectValue}"/>
Value
DependencyObject DependencyObject DependencyObject

The object that gets focus when a user presses the Directional Pad (D-pad) down.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

XYFocusDown is supported only on the Xbox device family, and only when using a game pad or remote control. The property is ignored otherwise.

For more info about this property, see the XY focus navigation and interaction section of the Designing for Xbox and TV article.

XYFocusDown="{x:Bind commandBar2}"

Version compatibility

The XYFocusDown property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "XYFocusDown"))
{
    button1.XYFocusDown = button2;
}

XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy XYFocusDownNavigationStrategy

Inherited from UIElement

XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty XYFocusDownNavigationStrategyProperty

Inherited from UIElement

XYFocusDownProperty XYFocusDownProperty XYFocusDownProperty

Identifies the XYFocusDown dependency property.

public : static DependencyProperty XYFocusDownProperty { get; }
public static DependencyProperty XYFocusDownProperty { get; }
Public Static ReadOnly Property XYFocusDownProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the XYFocusDown dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

XYFocusKeyboardNavigation XYFocusKeyboardNavigation XYFocusKeyboardNavigation

Inherited from UIElement

XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty XYFocusKeyboardNavigationProperty

Inherited from UIElement

XYFocusLeft XYFocusLeft XYFocusLeft

Gets or sets the object that gets focus when a user presses the Directional Pad (D-pad) left.

public : DependencyObject XYFocusLeft { get; set; }
public DependencyObject XYFocusLeft { get; set; }
Public ReadWrite Property XYFocusLeft As DependencyObject
<control XYFocusLeft="{x:Bind dependencyObjectValue}"/>
Value
DependencyObject DependencyObject DependencyObject

The object that gets focus when a user presses the Directional Pad (D-pad) left.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

XYFocusLeft is supported only on the Xbox device family, and only when using a game pad or remote control. The property is ignored otherwise.

For more info about this property, see the XY focus navigation and interaction section of the Designing for Xbox and TV article.

Version compatibility

The XYFocusLeft property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "XYFocusLeft"))
{
    button1.XYFocusLeft = button2;
}

XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy XYFocusLeftNavigationStrategy

Inherited from UIElement

XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty XYFocusLeftNavigationStrategyProperty

Inherited from UIElement

XYFocusLeftProperty XYFocusLeftProperty XYFocusLeftProperty

Identifies the XYFocusLeft dependency property.

public : static DependencyProperty XYFocusLeftProperty { get; }
public static DependencyProperty XYFocusLeftProperty { get; }
Public Static ReadOnly Property XYFocusLeftProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the XYFocusLeft dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

XYFocusRight XYFocusRight XYFocusRight

Gets or sets the object that gets focus when a user presses the Directional Pad (D-pad) right.

public : DependencyObject XYFocusRight { get; set; }
public DependencyObject XYFocusRight { get; set; }
Public ReadWrite Property XYFocusRight As DependencyObject
<control XYFocusRight="{x:Bind dependencyObjectValue}"/>
Value
DependencyObject DependencyObject DependencyObject

The object that gets focus when a user presses the Directional Pad (D-pad) right.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

XYFocusRight is supported only on the Xbox device family, and only when using a game pad or remote control. The property is ignored otherwise.

For more info about this property, see the XY focus navigation and interaction section of the Designing for Xbox and TV article.

Version compatibility

The XYFocusRight property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "XYFocusRight"))
{
    button1.XYFocusRight = button2;
}

XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy XYFocusRightNavigationStrategy

Inherited from UIElement

XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty XYFocusRightNavigationStrategyProperty

Inherited from UIElement

XYFocusRightProperty XYFocusRightProperty XYFocusRightProperty

Identifies the XYFocusRight dependency property.

public : static DependencyProperty XYFocusRightProperty { get; }
public static DependencyProperty XYFocusRightProperty { get; }
Public Static ReadOnly Property XYFocusRightProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the XYFocusRight dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

XYFocusUp XYFocusUp XYFocusUp

Gets or sets the object that gets focus when a user presses the Directional Pad (D-pad) up.

public : DependencyObject XYFocusUp { get; set; }
public DependencyObject XYFocusUp { get; set; }
Public ReadWrite Property XYFocusUp As DependencyObject
<control XYFocusUp="{x:Bind dependencyObjectValue}"/>
Value
DependencyObject DependencyObject DependencyObject

The object that gets focus when a user presses the Directional Pad (D-pad) up.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

XYFocusUp is supported only on the Xbox device family, and only when using a game pad or remote control. The property is ignored otherwise.

For more info about this property, see the XY focus navigation and interaction section of the Designing for Xbox and TV article.

Version compatibility

The XYFocusUp property is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.


if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Control", "XYFocusUp"))
{
    button1.XYFocusUp = button2;
}

XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy XYFocusUpNavigationStrategy

Inherited from UIElement

XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty XYFocusUpNavigationStrategyProperty

Inherited from UIElement

XYFocusUpProperty XYFocusUpProperty XYFocusUpProperty

Identifies the XYFocusUp dependency property.

public : static DependencyProperty XYFocusUpProperty { get; }
public static DependencyProperty XYFocusUpProperty { get; }
Public Static ReadOnly Property XYFocusUpProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the XYFocusUp dependency property.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Methods

AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean) AddHandler(RoutedEvent,Object,Boolean)

Inherited from UIElement

ApplyTemplate() ApplyTemplate() ApplyTemplate()

Loads the relevant control template so that its parts can be referenced.

public : Platform::Boolean ApplyTemplate()
public bool ApplyTemplate()
Public Function ApplyTemplate() As bool
Returns
Platform::Boolean bool bool

A value that indicates whether the visual tree was rebuilt by this call. True if the tree was rebuilt; false if the previous visual tree was retained.

Arrange(Rect) Arrange(Rect) Arrange(Rect)

Inherited from UIElement

ArrangeOverride(Size) ArrangeOverride(Size) ArrangeOverride(Size)

Inherited from FrameworkElement

CancelDirectManipulations CancelDirectManipulations CancelDirectManipulations

Inherited from UIElement

CapturePointer(Pointer) CapturePointer(Pointer) CapturePointer(Pointer)

Inherited from UIElement

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Inherited from DependencyObject

DeferTree(DependencyObject) DeferTree(DependencyObject) DeferTree(DependencyObject)

Inherited from FrameworkElement

FindName(String) FindName(String) FindName(String)

Inherited from FrameworkElement

FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect) FindSubElementsForTouchTargeting(Point,Rect)

Inherited from UIElement

Focus(FocusState) Focus(FocusState) Focus(FocusState)

Attempts to set the focus on the control.

public : Platform::Boolean Focus(FocusState value)
public bool Focus(FocusState value)
Public Function Focus(value As FocusState) As bool
Parameters
value
FocusState FocusState FocusState

Specifies how focus was set, as a value of the enumeration.

Returns
Platform::Boolean bool bool

true if focus was set to the control, or focus was already on the control. false if the control is not focusable.

Remarks

You can't remove focus from a control by calling this method with Unfocused as the parameter. This value is not allowed and causes an exception. To remove focus from a control, set focus to a different control.

You typically pass FocusState.Programmatic as the parameter to indicate the control obtained focus through a deliberate call to the Focus method. For example, if clicking an "Edit" button causes focus to be set on a TextBox, use the Programmatic focus state.

Pass FocusState.Pointer if you’re setting focus as the direct result of a pointer interaction. Pass FocusState.Keyboard as the parameter if you’re setting focus as a result of a keyboard interaction, like a tab sequence or key press. For example, if you’re implementing an ItemsControl and handle key presses to let the user move focus between items in the control, use the Keyboard focus state when you call Focus in your key press handler.

Note

In Windows 8, when FocusState is Programmatic, the keyboard focus visual is shown even if the prior method of input was pointer. In Windows 8.1, when you call Focus (FocusState.Programmatic), the prior FocusState, either Pointer or Keyboard, is retained so that the correct focus visual is shown. This means that if you check the value of the FocusState property after you call Focus (FocusState.Programmatic), the FocusState property will have a value of either Pointer or Keyboard.

In an app that’s compiled for Windows 8, but run in Windows 8.1, the Windows 8 behavior is retained. The FocusState property value is Programmatic and the keyboard focus visual is shown.

See Also

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Inherited from DependencyObject

GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty) GetBindingExpression(DependencyProperty)

Inherited from FrameworkElement

GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder GetChildrenInTabFocusOrder

Inherited from UIElement

GetIsTemplateFocusTarget(FrameworkElement) GetIsTemplateFocusTarget(FrameworkElement) GetIsTemplateFocusTarget(FrameworkElement)

Gets the value of the Control.IsTemplateFocusTarget XAML attached property for the target element.

public : static Platform::Boolean GetIsTemplateFocusTarget(FrameworkElement element)
public static bool GetIsTemplateFocusTarget(FrameworkElement element)
Public Static Function GetIsTemplateFocusTarget(element As FrameworkElement) As bool
Parameters
element
FrameworkElement FrameworkElement FrameworkElement

The object from which the property value is read.

Returns
Platform::Boolean bool bool

The Control.IsTemplateFocusTarget XAML attached property value of the specified object.

Remarks

This method is a utility method for the property system, and isn't used in most app scenarios. In most cases you set the Control.IsTemplateFocusTarget XAML attached property in XAML and won't need this method. For more info, see the Control.IsTemplateFocusTarget attached property.

See Also

GetIsTemplateKeyTipTarget(DependencyObject) GetIsTemplateKeyTipTarget(DependencyObject) GetIsTemplateKeyTipTarget(DependencyObject)

Gets the value of the Control.IsTemplateKeyTipTarget XAML attached property for the target element.

public : static Platform::Boolean GetIsTemplateKeyTipTarget(DependencyObject element)
public static bool GetIsTemplateKeyTipTarget(DependencyObject element)
Public Static Function GetIsTemplateKeyTipTarget(element As DependencyObject) As bool
Parameters
element
DependencyObject DependencyObject DependencyObject

The object from which the property value is read.

Returns
Platform::Boolean bool bool

The Control.IsTemplateKeyTipTarget XAML attached property value of the specified object.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

This method is a utility method for the property system, and isn't used in most app scenarios. In most cases you set the Control.IsTemplateKeytipTarget XAML attached property in XAML and won't need this method. For more info, see the Control.IsTemplateKeyTipTarget attached property.

GetTemplateChild(String) GetTemplateChild(String) GetTemplateChild(String)

Retrieves the named element in the instantiated ControlTemplate visual tree.

protected : DependencyObject GetTemplateChild(Platform::String childName)
protected DependencyObject GetTemplateChild(String childName)
Protected Function GetTemplateChild(childName As String) As DependencyObject
Parameters
childName
Platform::String String String

The name of the element to find.

Returns

The named element from the template, if the element is found. Can return null if no element with name childName was found in the template.

Remarks

You call GetTemplateChild to get references to objects in a controls Template after it's instantiated. The ControlTemplate is instantiated in the OnApplyTemplate method. You can use the GetTemplateChild method inside your OnApplyTemplate override and keep a reference to the objects you need.

See Also

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Inherited from DependencyObject

GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean) GoToElementStateCore(String,Boolean)

Inherited from FrameworkElement

InvalidateArrange InvalidateArrange InvalidateArrange

Inherited from UIElement

InvalidateMeasure InvalidateMeasure InvalidateMeasure

Inherited from UIElement

Measure(Size) Measure(Size) Measure(Size)

Inherited from UIElement

MeasureOverride(Size) MeasureOverride(Size) MeasureOverride(Size)

Inherited from FrameworkElement

OnApplyTemplate OnApplyTemplate OnApplyTemplate

Inherited from FrameworkElement

OnCharacterReceived(CharacterReceivedRoutedEventArgs) OnCharacterReceived(CharacterReceivedRoutedEventArgs) OnCharacterReceived(CharacterReceivedRoutedEventArgs)

Called before the CharacterReceived event occurs.

protected : virtual void OnCharacterReceived(CharacterReceivedRoutedEventArgs e)
protected virtual void OnCharacterReceived(CharacterReceivedRoutedEventArgs e)
Protected Overridable Function OnCharacterReceived(e As CharacterReceivedRoutedEventArgs) As void
Parameters
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)
See Also

OnCreateAutomationPeer OnCreateAutomationPeer OnCreateAutomationPeer

Inherited from UIElement

OnDisconnectVisualChildren OnDisconnectVisualChildren OnDisconnectVisualChildren

Inherited from UIElement

OnDoubleTapped(DoubleTappedRoutedEventArgs) OnDoubleTapped(DoubleTappedRoutedEventArgs) OnDoubleTapped(DoubleTappedRoutedEventArgs)

Called before the DoubleTapped event occurs.

protected : virtual void OnDoubleTapped(DoubleTappedRoutedEventArgs e)
protected virtual void OnDoubleTapped(DoubleTappedRoutedEventArgs e)
Protected Overridable Function OnDoubleTapped(e As DoubleTappedRoutedEventArgs) As void
Parameters
See Also

OnDragEnter(DragEventArgs) OnDragEnter(DragEventArgs) OnDragEnter(DragEventArgs)

Called before the DragEnter event occurs.

protected : virtual void OnDragEnter(DragEventArgs e)
protected virtual void OnDragEnter(DragEventArgs e)
Protected Overridable Function OnDragEnter(e As DragEventArgs) As void
Parameters
e
DragEventArgs DragEventArgs DragEventArgs

Event data for the event.

See Also

OnDragLeave(DragEventArgs) OnDragLeave(DragEventArgs) OnDragLeave(DragEventArgs)

Called before the DragLeave event occurs.

protected : virtual void OnDragLeave(DragEventArgs e)
protected virtual void OnDragLeave(DragEventArgs e)
Protected Overridable Function OnDragLeave(e As DragEventArgs) As void
Parameters
e
DragEventArgs DragEventArgs DragEventArgs

Event data for the event.

See Also

OnDragOver(DragEventArgs) OnDragOver(DragEventArgs) OnDragOver(DragEventArgs)

Called before the DragOver event occurs.

protected : virtual void OnDragOver(DragEventArgs e)
protected virtual void OnDragOver(DragEventArgs e)
Protected Overridable Function OnDragOver(e As DragEventArgs) As void
Parameters
e
DragEventArgs DragEventArgs DragEventArgs

Event data for the event.

See Also

OnDrop(DragEventArgs) OnDrop(DragEventArgs) OnDrop(DragEventArgs)

Called before the Drop event occurs.

protected : virtual void OnDrop(DragEventArgs e)
protected virtual void OnDrop(DragEventArgs e)
Protected Overridable Function OnDrop(e As DragEventArgs) As void
Parameters
e
DragEventArgs DragEventArgs DragEventArgs

Event data for the event.

See Also

OnGotFocus(RoutedEventArgs) OnGotFocus(RoutedEventArgs) OnGotFocus(RoutedEventArgs)

Called before the GotFocus event occurs.

protected : virtual void OnGotFocus(RoutedEventArgs e)
protected virtual void OnGotFocus(RoutedEventArgs e)
Protected Overridable Function OnGotFocus(e As RoutedEventArgs) As void
Parameters
e
RoutedEventArgs RoutedEventArgs RoutedEventArgs

The data for the event.

See Also

OnHolding(HoldingRoutedEventArgs) OnHolding(HoldingRoutedEventArgs) OnHolding(HoldingRoutedEventArgs)

Called before the Holding event occurs.

protected : virtual void OnHolding(HoldingRoutedEventArgs e)
protected virtual void OnHolding(HoldingRoutedEventArgs e)
Protected Overridable Function OnHolding(e As HoldingRoutedEventArgs) As void
Parameters
See Also

OnKeyDown(KeyRoutedEventArgs) OnKeyDown(KeyRoutedEventArgs) OnKeyDown(KeyRoutedEventArgs)

Called before the KeyDown event occurs.

protected : virtual void OnKeyDown(KeyRoutedEventArgs e)
protected virtual void OnKeyDown(KeyRoutedEventArgs e)
Protected Overridable Function OnKeyDown(e As KeyRoutedEventArgs) As void
Parameters

Remarks

As it's implemented directly on Control, OnKeyDown has an empty implementation. But each ancestor in a control's hierarchy may have provided an implementation. You won't be able to see this implementation because it's internal native code. In some cases a control will already have existing On* overrides that mark the event Handled. For key events, controls are usually only handling for certain keys, by checking values in KeyRoutedEventArgs. For example, ButtonBase detects the Space key as a way to fire Click. Control code or your code probably shouldn't be suppressing all key events, because it's a common pattern to let key events bubble to the root visual so that they can be shortcuts or accelerators for app interaction. For more info see Keyboard interactions.

See Also

OnKeyUp(KeyRoutedEventArgs) OnKeyUp(KeyRoutedEventArgs) OnKeyUp(KeyRoutedEventArgs)

Called before the KeyUp event occurs.

protected : virtual void OnKeyUp(KeyRoutedEventArgs e)
protected virtual void OnKeyUp(KeyRoutedEventArgs e)
Protected Overridable Function OnKeyUp(e As KeyRoutedEventArgs) As void
Parameters

Remarks

As it's implemented directly on Control, OnKeyUp has an empty implementation. But each ancestor in a control's hierarchy may have provided an implementation. You won't be able to see this implementation because it's internal native code. In some cases a control will already have existing On* overrides that mark the event Handled. For key events, controls are usually only handling for certain keys, by checking values in KeyRoutedEventArgs. For example, ButtonBase detects the Space key as a way to fire Click. Control code or your code probably shouldn't be suppressing all key events, because it's a common pattern to let key events bubble to the root visual so that they can be shortcuts or accelerators for app interaction. For more info see Keyboard interactions.

See Also

OnLostFocus(RoutedEventArgs) OnLostFocus(RoutedEventArgs) OnLostFocus(RoutedEventArgs)

Called before the LostFocus event occurs.

protected : virtual void OnLostFocus(RoutedEventArgs e)
protected virtual void OnLostFocus(RoutedEventArgs e)
Protected Overridable Function OnLostFocus(e As RoutedEventArgs) As void
Parameters
e
RoutedEventArgs RoutedEventArgs RoutedEventArgs

The data for the event.

See Also

OnManipulationCompleted(ManipulationCompletedRoutedEventArgs) OnManipulationCompleted(ManipulationCompletedRoutedEventArgs) OnManipulationCompleted(ManipulationCompletedRoutedEventArgs)

Called before the ManipulationCompleted event occurs.

protected : virtual void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e)
protected virtual void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e)
Protected Overridable Function OnManipulationCompleted(e As ManipulationCompletedRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

Windows 8 doesn't fire ManipulationCompleted in cases where the inertial phase has started (and ManipulationInertiaStarting has fired) but the user has tapped on the item before it's finished scrolling, which cancels the inertial phase visually. The issue is fixed starting with Windows 8.1; ManipulationCompleted is fired as soon as the tap action cancels the inertial phase.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

See Also

OnManipulationDelta(ManipulationDeltaRoutedEventArgs) OnManipulationDelta(ManipulationDeltaRoutedEventArgs) OnManipulationDelta(ManipulationDeltaRoutedEventArgs)

Called before the ManipulationDelta event occurs.

protected : virtual void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e)
protected virtual void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e)
Protected Overridable Function OnManipulationDelta(e As ManipulationDeltaRoutedEventArgs) As void
Parameters
See Also

OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs) OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs) OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs)

Called before the ManipulationInertiaStarting event occurs.

protected : virtual void OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs e)
protected virtual void OnManipulationInertiaStarting(ManipulationInertiaStartingRoutedEventArgs e)
Protected Overridable Function OnManipulationInertiaStarting(e As ManipulationInertiaStartingRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

Windows 8 doesn't fire ManipulationCompleted in cases where the inertial phase has started (and ManipulationInertiaStarting has fired) but the user has tapped on the item before it's finished scrolling, which cancels the inertial phase visually. The issue is fixed starting with Windows 8.1; ManipulationCompleted is fired as soon as the tap action cancels the inertial phase.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

See Also

OnManipulationStarted(ManipulationStartedRoutedEventArgs) OnManipulationStarted(ManipulationStartedRoutedEventArgs) OnManipulationStarted(ManipulationStartedRoutedEventArgs)

Called before the ManipulationStarted event occurs.

protected : virtual void OnManipulationStarted(ManipulationStartedRoutedEventArgs e)
protected virtual void OnManipulationStarted(ManipulationStartedRoutedEventArgs e)
Protected Overridable Function OnManipulationStarted(e As ManipulationStartedRoutedEventArgs) As void
Parameters
See Also

OnManipulationStarting(ManipulationStartingRoutedEventArgs) OnManipulationStarting(ManipulationStartingRoutedEventArgs) OnManipulationStarting(ManipulationStartingRoutedEventArgs)

Called before the ManipulationStarting event occurs.

protected : virtual void OnManipulationStarting(ManipulationStartingRoutedEventArgs e)
protected virtual void OnManipulationStarting(ManipulationStartingRoutedEventArgs e)
Protected Overridable Function OnManipulationStarting(e As ManipulationStartingRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

Windows 8 had an issue with firing this event if multiple gestures happened in a short period of time. For example, Windows 8 might only fire ManipulationStarting for the first gesture and not the second. The issue is fixed starting with Windows 8.1; multiple starting gestures processed by the input system each fire a distinct ManipulationStarting event.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

See Also

OnPointerCanceled(PointerRoutedEventArgs) OnPointerCanceled(PointerRoutedEventArgs) OnPointerCanceled(PointerRoutedEventArgs)

Called before the PointerCanceled event occurs.

protected : virtual void OnPointerCanceled(PointerRoutedEventArgs e)
protected virtual void OnPointerCanceled(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerCanceled(e As PointerRoutedEventArgs) As void
Parameters
See Also

OnPointerCaptureLost(PointerRoutedEventArgs) OnPointerCaptureLost(PointerRoutedEventArgs) OnPointerCaptureLost(PointerRoutedEventArgs)

Called before the PointerCaptureLost event occurs.

protected : virtual void OnPointerCaptureLost(PointerRoutedEventArgs e)
protected virtual void OnPointerCaptureLost(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerCaptureLost(e As PointerRoutedEventArgs) As void
Parameters
See Also

OnPointerEntered(PointerRoutedEventArgs) OnPointerEntered(PointerRoutedEventArgs) OnPointerEntered(PointerRoutedEventArgs)

Called before the PointerEntered event occurs.

protected : virtual void OnPointerEntered(PointerRoutedEventArgs e)
protected virtual void OnPointerEntered(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerEntered(e As PointerRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

For Windows 8, generally the PointerEntered event won't fire if the onscreen cursor (or stylus or touchpoint) did not actually move. For example, PointerEntered doesn't fire if the mouse and its onscreen cursor remains stationary, and an object with a PointerEntered handler has its position translated or otherwise adjusted to move underneath the onscreen cursor. Or, PointerEntered doesn't fire if an element like a popup or flyout disappears and the pointer is now over a new element (but pointer hasn't moved yet). Related to this is the PointerExited behavior. For example, if a popup is dismissed programmatically, it won't fire PointerExited if the pointer didn't move as the cause of dismissing it. You would still get a PointerEntered event if the pointer moves while over the newly revealed element, but that's up to the user whether that will happen, and it happens at the time of movement, not the moment of dismissal. In short, trying to use the last element that fired PointerEntered for pointer state determination in the app UI isn't comprehensive in Windows 8, and there are many scenarios where PointerEntered and PointerExited won't pair up. This impacts the visual states for controls that use PointerEntered and PointerExited as triggers also.

Starting with Windows 8.1, PointerExited is fired for any case where the pointer had at one time fired a PointerEntered event, but some UI state change happens where the pointer is no longer within that element. This includes cases where the whole element disappears. And if the pointer is now over a different element because a previous element disappeared, that element fires PointerEntered, even if the pointer never moves. Elements that set their Visibility to Collapsed programmatically is one way that elements might disappear from UI, and the Windows 8.1 behavior accounts for this and will fire PointerExited for the **Collapsed ** element and PointerEntered for the newly revealed element.

If you migrate your app code from Windows 8 to Windows 8.1 you may want to account for this behavior change, because it results in PointerExited and PointerEntered being fired in cases where they wouldn't have fired before.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

See Also

OnPointerExited(PointerRoutedEventArgs) OnPointerExited(PointerRoutedEventArgs) OnPointerExited(PointerRoutedEventArgs)

Called before the PointerExited event occurs.

protected : virtual void OnPointerExited(PointerRoutedEventArgs e)
protected virtual void OnPointerExited(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerExited(e As PointerRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

For Windows 8, generally the PointerEntered event won't fire if the onscreen cursor (or stylus or touchpoint) did not actually move. For example, PointerEntered doesn't fire if the mouse and its onscreen cursor remains stationary, and an object with a PointerEntered handler has its position translated or otherwise adjusted to move underneath the onscreen cursor. Or, PointerEntered doesn't fire if an element like a popup or flyout disappears and the pointer is now over a new element (but pointer hasn't moved yet). Related to this is the PointerExited behavior. For example, if a popup is dismissed programmatically, it won't fire PointerExited if the pointer didn't move as the cause of dismissing it. You would still get a PointerEntered event if the pointer moves while over the newly revealed element, but that's up to the user whether that will happen, and it happens at the time of movement, not the moment of dismissal. In short, trying to use the last element that fired PointerEntered for pointer state determination in the app UI isn't comprehensive in Windows 8, and there are many scenarios where PointerEntered and PointerExited won't pair up. This impacts the visual states for controls that use PointerEntered and PointerExited as triggers also.

Starting with Windows 8.1, PointerExited is fired for any case where the pointer had at one time fired a PointerEntered event, but some UI state change happens where the pointer is no longer within that element. This includes cases where the whole element disappears. And if the pointer is now over a different element because a previous element disappeared, that element fires PointerEntered, even if the pointer never moves. Elements that set their Visibility to Collapsed programmatically is one way that elements might disappear from UI, and the Windows 8.1 behavior accounts for this and will fire PointerExited for the **Collapsed ** element and PointerEntered for the newly revealed element.

If you migrate your app code from Windows 8 to Windows 8.1 you may want to account for this behavior change, because it results in PointerExited and PointerEntered being fired in cases where they wouldn't have fired before.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

See Also

OnPointerMoved(PointerRoutedEventArgs) OnPointerMoved(PointerRoutedEventArgs) OnPointerMoved(PointerRoutedEventArgs)

Called before the PointerMoved event occurs.

protected : virtual void OnPointerMoved(PointerRoutedEventArgs e)
protected virtual void OnPointerMoved(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerMoved(e As PointerRoutedEventArgs) As void
Parameters
See Also

OnPointerPressed(PointerRoutedEventArgs) OnPointerPressed(PointerRoutedEventArgs) OnPointerPressed(PointerRoutedEventArgs)

Called before the PointerPressed event occurs.

protected : virtual void OnPointerPressed(PointerRoutedEventArgs e)
protected virtual void OnPointerPressed(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerPressed(e As PointerRoutedEventArgs) As void
Parameters

Remarks

As it's implemented directly on Control, OnPointerPressed has an empty implementation. But each ancestor in a control's hierarchy may have provided an implementation. You won't be able to see this implementation because it's internal native code. In some cases a control will already have existing On* overrides that mark the event Handled. OnPointerPressed happens to be an On* event that several Windows Runtime XAML controls have provided overrides for. For example, ButtonBase has overridden OnPointerPressed to mark the event Handled. What all buttons do instead is to then raise the Click event that represents a higher-level event behavior for that control. That means you won't easily be able to handle UIElement.PointerPressed on a button, but you probably shouldn't be handling it anyways for most scenarios. Just use Click instead.

See Also

OnPointerReleased(PointerRoutedEventArgs) OnPointerReleased(PointerRoutedEventArgs) OnPointerReleased(PointerRoutedEventArgs)

Called before the PointerReleased event occurs.

protected : virtual void OnPointerReleased(PointerRoutedEventArgs e)
protected virtual void OnPointerReleased(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerReleased(e As PointerRoutedEventArgs) As void
Parameters
See Also

OnPointerWheelChanged(PointerRoutedEventArgs) OnPointerWheelChanged(PointerRoutedEventArgs) OnPointerWheelChanged(PointerRoutedEventArgs)

Called before the PointerWheelChanged event occurs.

protected : virtual void OnPointerWheelChanged(PointerRoutedEventArgs e)
protected virtual void OnPointerWheelChanged(PointerRoutedEventArgs e)
Protected Overridable Function OnPointerWheelChanged(e As PointerRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

For Windows 8, track pad device gestures that were input-handled by a ScrollViewer control part were interpreted as mouse wheel input, and thus would fire a PointerWheelChanged event. Starting with Windows 8.1, ScrollViewer uses an underlying manipulation logic that interprets track pad gestures as actions that the ScrollViewer responds to, and thus the gesture is considered handled by the control and the PointerWheelChanged event is not fired anymore.

If you migrate your app code from Windows 8 to Windows 8.1 you may want to account for this behavior change, because it results in PointerWheelChanged being fired in fewer cases. Also, the behavior that's now built-in to ScrollViewer may be duplicating what your handler would have done.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

See Also

OnPreviewKeyDown(KeyRoutedEventArgs) OnPreviewKeyDown(KeyRoutedEventArgs) OnPreviewKeyDown(KeyRoutedEventArgs)

Called before the PreviewKeyDown event occurs.

protected : virtual void OnPreviewKeyDown(KeyRoutedEventArgs e)
protected virtual void OnPreviewKeyDown(KeyRoutedEventArgs e)
Protected Overridable Function OnPreviewKeyDown(e As KeyRoutedEventArgs) As void
Parameters
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

OnPreviewKeyUp(KeyRoutedEventArgs) OnPreviewKeyUp(KeyRoutedEventArgs) OnPreviewKeyUp(KeyRoutedEventArgs)

Called before the PreviewKeyUp event occurs.

protected : virtual void OnPreviewKeyUp(KeyRoutedEventArgs e)
protected virtual void OnPreviewKeyUp(KeyRoutedEventArgs e)
Protected Overridable Function OnPreviewKeyUp(e As KeyRoutedEventArgs) As void
Parameters
Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs) OnProcessKeyboardAccelerators(ProcessKeyboardAcceleratorEventArgs)

Inherited from UIElement

OnRightTapped(RightTappedRoutedEventArgs) OnRightTapped(RightTappedRoutedEventArgs) OnRightTapped(RightTappedRoutedEventArgs)

Called before the RightTapped event occurs.

protected : virtual void OnRightTapped(RightTappedRoutedEventArgs e)
protected virtual void OnRightTapped(RightTappedRoutedEventArgs e)
Protected Overridable Function OnRightTapped(e As RightTappedRoutedEventArgs) As void
Parameters

Remarks

Windows 8 behavior

Windows 8 had an issue with the data for the RightTapped event, where the X and Y values for the point you'd get from RightTappedRoutedEventArgs.GetPosition were reversed (X was really Y; Y was really X). This issue has been fixed starting with Windows 8.1. But if you're retargeting a Windows 8 app for Windows 8.1, you might have had code that worked around this issue by swapping the X and Y back. If so, remove that code when you retarget because the issue is now fixed.

Apps that were compiled for Windows 8 but running on Windows 8.1 continue to use the Windows 8 behavior.

Also, Windows 8 didn't include default key handling for Shift+F10 that would fire this event and then display context menus. Shift+F10 is typically a secondary key combination for the VK_APP virtual key value (the Properties key), and thus Shift+F10 might be expected to fire RightTapped too. This issue has been fixed starting with Windows 8.1; Shift+F10 now fires RightTapped. You can see this change as default event handling on some controls that have default context menus for text, such as TextBox, or when invoking custom menus and flyouts.

Apps that were compiled for Windows 8 but running on Windows 8.1 do not use this Windows 8 behavior, they use the corrected Windows 8.1 behavior.

See Also

OnTapped(TappedRoutedEventArgs) OnTapped(TappedRoutedEventArgs) OnTapped(TappedRoutedEventArgs)

Called before the Tapped event occurs.

protected : virtual void OnTapped(TappedRoutedEventArgs e)
protected virtual void OnTapped(TappedRoutedEventArgs e)
Protected Overridable Function OnTapped(e As TappedRoutedEventArgs) As void
Parameters
See Also

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Inherited from DependencyObject

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Inherited from DependencyObject

ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer) ReleasePointerCapture(Pointer)

Inherited from UIElement

ReleasePointerCaptures ReleasePointerCaptures ReleasePointerCaptures

Inherited from UIElement

RemoveFocusEngagement() RemoveFocusEngagement() RemoveFocusEngagement()

Releases focus from the control boundaries for a control that has focus engagement (for game pad/remote interaction).

public : void RemoveFocusEngagement()
public void RemoveFocusEngagement()
Public Function RemoveFocusEngagement() As void
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

Focus engagement makes it easier to use a game pad or remote control to interact with an app. Setting focus engagement does not affect keyboard or other input devices.

When the IsFocusEngagementEnabled property is set to true, it marks the control as requiring focus engagement. This means that the user must press the A/Select button to "engage" the control and interact with it. When they are finished, they can press the B/Back button to disengage the control and navigate away from it. You can call RemoveFocusEngagement to programmatically disengage a control.

For more info, see the Focus engagement section of the Designing for Xbox and TV article.

Version compatibility

The RemoveFocusEngagement method is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not call this method without first performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this method before you use it.

if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Controls.Control", "RemoveFocusEngagement"))
{
    control1.RemoveFocusEngagement();
}

RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object) RemoveHandler(RoutedEvent,Object)

Inherited from UIElement

SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase) SetBinding(DependencyProperty,BindingBase)

Inherited from FrameworkElement

SetIsTemplateFocusTarget(FrameworkElement, Boolean) SetIsTemplateFocusTarget(FrameworkElement, Boolean) SetIsTemplateFocusTarget(FrameworkElement, Boolean)

Sets the value of the Control.IsTemplateFocusTarget XAML attached property for a target element.

public : static void SetIsTemplateFocusTarget(FrameworkElement element, bool value)
public static void SetIsTemplateFocusTarget(FrameworkElement element, Boolean value)
Public Static Function SetIsTemplateFocusTarget(element As FrameworkElement, value As Boolean) As void
Parameters
element
FrameworkElement FrameworkElement FrameworkElement

The object to which the property value is written.

value
bool Boolean Boolean

The value to set.

Remarks

This method is a utility method for the property system, and isn't used in most app scenarios. In most cases you set the Control.IsTemplateFocusTarget XAML attached property in XAML and won't need this method. For more info, see the Control.IsTemplateFocusTarget attached property.

SetIsTemplateKeyTipTarget(DependencyObject, Boolean) SetIsTemplateKeyTipTarget(DependencyObject, Boolean) SetIsTemplateKeyTipTarget(DependencyObject, Boolean)

Sets the value of the Control.IsTemplateKeyTipTarget XAML attached property for a target element.

public : static void SetIsTemplateKeyTipTarget(DependencyObject element, bool value)
public static void SetIsTemplateKeyTipTarget(DependencyObject element, Boolean value)
Public Static Function SetIsTemplateKeyTipTarget(element As DependencyObject, value As Boolean) As void
Parameters
element
DependencyObject DependencyObject DependencyObject

The object to which the property value is written.

value
bool Boolean Boolean

The value to set.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

This method is a utility method for the property system, and isn't used in most app scenarios. In most cases you set the Control.IsTemplateFocusTarget XAML attached property in XAML and won't need this method. For more info, see the Control.IsTemplateKeyTipTarget attached property.

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Inherited from DependencyObject

StartBringIntoView StartBringIntoView StartBringIntoView

Inherited from UIElement

StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions) StartBringIntoView(BringIntoViewOptions)

Inherited from UIElement

StartDragAsync(PointerPoint) StartDragAsync(PointerPoint) StartDragAsync(PointerPoint)

Inherited from UIElement

TransformToVisual(UIElement) TransformToVisual(UIElement) TransformToVisual(UIElement)

Inherited from UIElement

TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs) TryInvokeKeyboardAccelerator(ProcessKeyboardAcceleratorEventArgs)

Inherited from UIElement

TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer) TryStartDirectManipulation(Pointer)

Inherited from UIElement

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Inherited from DependencyObject

UpdateLayout UpdateLayout UpdateLayout

Inherited from UIElement

Events

AccessKeyDisplayDismissed AccessKeyDisplayDismissed AccessKeyDisplayDismissed

Inherited from UIElement

AccessKeyDisplayRequested AccessKeyDisplayRequested AccessKeyDisplayRequested

Inherited from UIElement

AccessKeyInvoked AccessKeyInvoked AccessKeyInvoked

Inherited from UIElement

ActualThemeChanged ActualThemeChanged ActualThemeChanged

Inherited from FrameworkElement

CharacterReceived CharacterReceived CharacterReceived

Inherited from UIElement

ContextCanceled ContextCanceled ContextCanceled

Inherited from UIElement

ContextRequested ContextRequested ContextRequested

Inherited from UIElement

DataContextChanged DataContextChanged DataContextChanged

Inherited from FrameworkElement

DoubleTapped DoubleTapped DoubleTapped

Inherited from UIElement

DragEnter DragEnter DragEnter

Inherited from UIElement

DragLeave DragLeave DragLeave

Inherited from UIElement

DragOver DragOver DragOver

Inherited from UIElement

DragStarting DragStarting DragStarting

Inherited from UIElement

Drop Drop Drop

Inherited from UIElement

DropCompleted DropCompleted DropCompleted

Inherited from UIElement

FocusDisengaged FocusDisengaged FocusDisengaged

Occurs when focus is released from the control boundaries (for game pad/remote interaction).

public : event TypedEventHandler FocusDisengaged<Control, FocusDisengagedEventArgs>
public event TypedEventHandler FocusDisengaged<Control, FocusDisengagedEventArgs>
Public Event TypedEventHandler FocusDisengaged( Of ( Of Control ), ( Of FocusDisengagedEventArgs ))
<control FocusDisengaged="eventhandler"/>
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

For event data, see FocusDisengagedEventArgs.

Focus engagement makes it easier to use a game pad or remote control to interact with an app. Setting focus engagement does not affect keyboard or other input devices.

When the IsFocusEngagementEnabled property is set to true, it marks the control as requiring focus engagement. This means that the user must press the A/Select button to "engage" the control and interact with it. When they are finished, they can press the B/Back button to disengage the control and navigate away from it.

For more info, see the Focus engagement section of the Designing for Xbox and TV article.

Version compatibility

The FocusDisengaged event is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not connect this event without first performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this event before you use it.

<Slider x:Name="slider1" Loaded="Slider_Loaded"/>
private void Slider_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsEventPresent("Windows.UI.Xaml.Controls.Control", "FocusDisengaged"))
    {
        slider1.FocusDisengaged += Slider1_FocusDisengaged;
    }
}

FocusEngaged FocusEngaged FocusEngaged

Occurs when focus is constrained within the control boundaries (for game pad/remote interaction).

public : event TypedEventHandler FocusEngaged<Control, FocusEngagedEventArgs>
public event TypedEventHandler FocusEngaged<Control, FocusEngagedEventArgs>
Public Event TypedEventHandler FocusEngaged( Of ( Of Control ), ( Of FocusEngagedEventArgs ))
<control FocusEngaged="eventhandler"/>
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

For event data, see FocusEngagedEventArgs.

Focus engagement makes it easier to use a game pad or remote control to interact with an app. Setting focus engagement does not affect keyboard or other input devices.

When the IsFocusEngagementEnabled property is set to true, it marks the control as requiring focus engagement. This means that the user must press the A/Select button to "engage" the control and interact with it. When they are finished, they can press the B/Back button to disengage the control and navigate away from it.

For more info about this property, see the Focus engagement section of the Designing for Xbox and TV article.

Version compatibility

The FocusEngaged event is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not connect this event without first performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this event before you use it.

<Slider x:Name="slider1" Loaded="Slider_Loaded"/>
private void Slider_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsEventPresent("Windows.UI.Xaml.Controls.Control", "FocusEngaged"))
    {
        slider1.FocusEngaged += Slider1_FocusEngaged;
    }
}

GettingFocus GettingFocus GettingFocus

Inherited from UIElement

GotFocus GotFocus GotFocus

Inherited from UIElement

Holding Holding Holding

Inherited from UIElement

IsEnabledChanged IsEnabledChanged IsEnabledChanged

Occurs when the IsEnabled property changes.

public : event DependencyPropertyChangedEventHandler IsEnabledChanged<>
public event DependencyPropertyChangedEventHandler IsEnabledChanged<>
Public Event DependencyPropertyChangedEventHandler IsEnabledChanged( Of )
<control IsEnabledChanged="eventhandler"/>

Remarks

Whenever IsEnabled changes, that fires the IsEnabledChanged event. Controls might handle this event in order to change the visual states. The event has DependencyPropertyChangedEventArgs data, so you can determine the old and new values without having to use your own flags.

A control inherits the IsEnabled property from its parent control. For example, if a control that contains a button has IsEnabled set to false, the button's IsEnabled property is also false. When the parent's property changes, that fires IsEnabledChanged for each control where the value changes because of the value inheriting.

See Also

KeyDown KeyDown KeyDown

Inherited from UIElement

KeyUp KeyUp KeyUp

Inherited from UIElement

LayoutUpdated LayoutUpdated LayoutUpdated

Inherited from FrameworkElement

Loaded Loaded Loaded

Inherited from FrameworkElement

Loading Loading Loading

Inherited from FrameworkElement

LosingFocus LosingFocus LosingFocus

Inherited from UIElement

LostFocus LostFocus LostFocus

Inherited from UIElement

ManipulationCompleted ManipulationCompleted ManipulationCompleted

Inherited from UIElement

ManipulationDelta ManipulationDelta ManipulationDelta

Inherited from UIElement

ManipulationInertiaStarting ManipulationInertiaStarting ManipulationInertiaStarting

Inherited from UIElement

ManipulationStarted ManipulationStarted ManipulationStarted

Inherited from UIElement

ManipulationStarting ManipulationStarting ManipulationStarting

Inherited from UIElement

NoFocusCandidateFound NoFocusCandidateFound NoFocusCandidateFound

Inherited from UIElement

PointerCanceled PointerCanceled PointerCanceled

Inherited from UIElement

PointerCaptureLost PointerCaptureLost PointerCaptureLost

Inherited from UIElement

PointerEntered PointerEntered PointerEntered

Inherited from UIElement

PointerExited PointerExited PointerExited

Inherited from UIElement

PointerMoved PointerMoved PointerMoved

Inherited from UIElement

PointerPressed PointerPressed PointerPressed

Inherited from UIElement

PointerReleased PointerReleased PointerReleased

Inherited from UIElement

PointerWheelChanged PointerWheelChanged PointerWheelChanged

Inherited from UIElement

PreviewKeyDown PreviewKeyDown PreviewKeyDown

Inherited from UIElement

PreviewKeyUp PreviewKeyUp PreviewKeyUp

Inherited from UIElement

ProcessKeyboardAccelerators ProcessKeyboardAccelerators ProcessKeyboardAccelerators

Inherited from UIElement

RightTapped RightTapped RightTapped

Inherited from UIElement

SizeChanged SizeChanged SizeChanged

Inherited from FrameworkElement

Tapped Tapped Tapped

Inherited from UIElement

Unloaded Unloaded Unloaded

Inherited from FrameworkElement

See Also