Host Element

Hosts a child UI.

Syntax

<Host
    Alpha="float"
    AnimationsEnabled="{true | false}"
    CenterPointOffset="Vector3"
    CenterPointPercent="Vector3"
    ColorFilter="Color"
    DebugOutline="Color"
    FocusOrder="int"
    InputEnabled="{true | false}"
    Layout="{Anchor | Center | Dock | Fill | Form | Grid | HorizontalFlow | Rotate | Scale | VerticalFlow}"
    LayoutInput="LayoutInput"
    Margins="Inset"
    MaximumSize="Size"
    MinimumSize="Size"
    MouseInteractive="{true | false}"
    Name="string"
    Navigation="NavigationPolicies enumeration"
    Padding="Inset"
    Rotation="Rotation"
    Scale="Vector3"
    Source="string"
    Status="{Error | Loading | Success}"
    ThrowOnLoadError="{true | false}"
    TouchInteractive="{true | false}"
    Visible="{true | false}"
>
    <Animations />
    <Children />
    <Errors />
    <Layout />
    <LayoutInput />
</Host>

Attributes

Alpha

Specifies the opacity value for the view item. This value must be between 0.0 and 1.0.

AnimationsEnabled

Specifies whether animations are enabled for the view item and child elements.

Animations

Contains a list of elements that describe an animation. Possible elements are:

Animation

MergeAnimation

SwitchAnimation

TransformAnimation

TransformByAttributeAnimation

CenterPointOffset

Specifies a center point adjustment based on a pixel-offset value when applying a scale or rotation to the view item. This value is applied after the CenterPointPercent value has been applied if both are provided. Use the inline construction for the Vector3 structure.

CenterPointPercent

Specifies a center point adjustment based on a percentage value when applying a scale or rotation to the view item. This value must be between 0 and 1, where a value of 1 equals 100%. Use the inline construction for the Vector3 structure.

Children

Specifies the child elements for a view item. Possible child elements are:

Clip

ColorFill

Graphic

Host

Panel

Repeater

Scroller

Text

Video

ColorFilter

Indicates the Color filter to apply on top of the color of the view item.

DebugOutline

Enables and sets the Color of the debugging outline of the view item.

Errors

Lists reported error strings if the source failed to load.

FocusOrder

Specifies relative priorities to sibling view items within the container for determining which item has default focus when entering a UI. Values can range from 0 (the highest priority) to Int32.MaxValue (the lowest priority and the default).

InputEnabled

Indicates whether the hosted UI input is enabled.

Layout

Specifies the current layout associated with this view item. You can use the inline construction, or expanded syntax with the following child elements that define a layout:

AnchorLayout

DockLayout

FlowLayout

GridLayout

RotateLayout

ScaleLayout

LayoutInput

Specifies the layout input for use by parent layouts. You can use the inline construction to specify a reference to a layout element, or use expanded syntax with the following child elements that define input:

AnchorLayoutInput

DockLayoutInput

FormLayoutInput

Margins

An Inset structure that specifies extra spacing around the view item.

MaximumSize

Specifies the maximum Size, in pixels. If a maximum size is not specified or the maximum size is set to zero, the size will not be restricted.

MinimumSize

Specifies the minimum Size, in pixels. If a maximum size is not specified or the maximum size is set to zero, the size will not be restricted.

MouseInteractive

Determines whether the view item can receive and react to mouse input.

Name

Identifies this element.

Navigation

Specifies how the view item should behave during directional navigation. This value must be a member of the NavigationPolicies enumeration.

Padding

An Inset structure that specifies the extra spacing, in pixels, between the view item and its child elements.

Rotation

Applies a Rotation to the view item. Use the inline construction for this element.

Scale

A Vector3 structure that applies a scaling factor to the view item. Use the inline construction for this element.

Source

Contains the prefixed name or URI of the UI to create and host.

Status

Indicates the load status of the current source. This value is a member of the LoadResultStatus enumeration. This value is read-only.

ThrowOnLoadError

Indicates whether to throw an exception on failure to load source.

TouchInteractive

Determines whether the view item can receive and react to touch input.

Visible

Indicates whether the view item is visible.

Public Instance Methods

Method Description
AttachAnimation Dynamically adds an animation to the view item.
Cancel Cancels the current load of the source.
DetachAnimation Dynamically removes an animation from the view item.
ForceContentChange Manually forces a content change for animations.
ForceRefresh Forces the UI to reload.
NavigateInto Requests navigation into the view item to send focus to the view item or one of its children.

Remarks

Host is a frequently used view item, although it is not typically used explicitly as <Host/>. Any child UI placed within the Content attribute of a UI is a Host view item.

For example, this type of markup is very common:

<Mcml xmlns:ctl="file://Scenarios.SimpleButton.mcml">
...
    <ctl:SimpleButton Command="[Command]"/>

In reality, it is actually the following:

<Host
    Source="file://Scenarios.SimpleButton.mcml#SimpleButton"
    Command="[Command]"/>

Accessing the Source property on a Host element at run-time enables you to dynamically swap out child UIs at run-time.

Note Unless dynamic source swapping is intended, it is never recommended to use the full Host syntax. When the full Host syntax is used, all parse-time validation is lost for that Host (such as source and parameter type validation) as well as load-time Host source optimizations.

Requirements

Platform: Windows Vista Ultimate, Windows Vista Home Premium, and later

See Also