ContainerVisual Class


A node in the visual tree that can have children.

Equivalent WinUI class: Microsoft.UI.Composition.ContainerVisual.

public ref class ContainerVisual : Visual
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ContainerVisual : Visual
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 131072)]
class ContainerVisual : Visual
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public class ContainerVisual : Visual
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 131072)]
public class ContainerVisual : Visual
Public Class ContainerVisual
Inherits Visual
Object IInspectable CompositionObject Visual ContainerVisual

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)


// Set up Windows.UI.Composition Compositor, root ContainerVisual, and associate with
// the CoreWindow.

_compositor = new Compositor();

_root = _compositor.CreateContainerVisual();
_view.CompositionRootVisual = _root;

// Create a simple scene.

var child = _compositor.CreateSpriteVisual();
child.Brush = _compositor.CreateColorBrush(Color.FromArgb(0xFF, 0x00, 0xCC, 0x00));
child.Offset = new Vector2(50.0f, 50.0f);
child.Size = new Vector2(200, 200);

// App.cpp
struct SampleApp : implements<SampleApp, IFrameworkViewSource, IFrameworkView>
    void SetWindow(CoreWindow const& /* window */)
        // Set up Composition.
        m_compositor = Compositor{};
        m_target = m_compositor.CreateTargetForCurrentView();
        m_root = m_compositor.CreateContainerVisual();

        // Create a simple scene.
        auto child{ m_compositor.CreateSpriteVisual() };
        child.Brush(m_compositor.CreateColorBrush(ColorHelper::FromArgb(0xFF, 0x00, 0xCC, 0x00)));
        child.Offset({ 50.f, 50.f, 0.f });
        child.Size({ 200.f, 200.f });


    Compositor m_compositor{ nullptr };
    CompositionTarget m_target{ nullptr };
    ContainerVisual m_root{nullptr};
ref class MyClass
    Compositor ^ _compositor;
    CompositionTarget ^ _target;
    ContainerVisual ^ _root;

    void Initialize()
        // Set up Composition.

        _compositor = ref new Compositor();
        _target = _compositor->CreateTargetForCurrentView();
        _root = _compositor->CreateContainerVisual();
        _target->Root = _root;

        // Create a simple scene.

        auto child = _compositor->CreateSpriteVisual();
        child->Brush = _compositor.CreateColorBrush(ColorHelper::FromArgb(0xFF, 0x00, 0xCC, 0x00));
        child->Offset = float2(50.0f, 50.0f);
        child->Size = float2(200, 200);




The point on the visual to be positioned at the visual's offset. Value is normalized with respect to the size of the visual. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.AnchorPoint.

(Inherited from Visual)

Specifies whether the back face of the visual should be visible during a 3D transform.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.BackfaceVisibility.

(Inherited from Visual)

Specifies how to compose the edges of bitmaps and clips associated with a visual, or with all visuals in the subtree rooted at this visual. Setting BorderMode at a parent Visual will affect all children visuals in the subtree and can be selectively turned off at each child visual.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.BorderMode.

(Inherited from Visual)

The point about which rotation or scaling occurs. Animatable

Equivalent WinUI property: Microsoft.UI.Composition.Visual.CenterPoint.

(Inherited from Visual)

The children of the ContainerVisual.

Equivalent WinUI property: Microsoft.UI.Composition.ContainerVisual.Children.


Specifies the clipping region for the visual. When a visual is rendered, only the portion of the visual that falls inside the clipping region is displayed, while any content that extends outside the clipping region is clipped (that is, not displayed).

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Clip.

(Inherited from Visual)

A string to associate with the CompositionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.Comment.

(Inherited from CompositionObject)

Specifies how a visual's bitmap is blended with the screen.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.CompositeMode.

(Inherited from Visual)

The Compositor used to create this CompositionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.Compositor.

(Inherited from CompositionObject)

The dispatcher for the CompositionObject.

(Inherited from CompositionObject)

Gets the DispatcherQueue for the CompostionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.DispatcherQueue.

(Inherited from CompositionObject)

The collection of implicit animations attached to this object.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.ImplicitAnimations.

(Inherited from CompositionObject)

Gets or sets a value that indicates whether the visual sub-tree rooted at this visual participates in hit testing.

(Inherited from Visual)

Gets or sets a value that indicates whether the composition engine aligns the rendered visual with a pixel boundary.

(Inherited from Visual)

Indicates whether the visual and its entire subtree of child visuals is visible.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.IsVisible.

(Inherited from Visual)

The offset of the visual relative to its parent or for a root visual the offset relative to the upper-left corner of the windows that hosts the visual. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Offset.

(Inherited from Visual)

The opacity of the visual. Animatable.

The opacity property determines the transparency, if any, of the Visual and is a value from 0 to 1. 0 is fully transparent and 1 is full opaque. A Visual with an Opacity property of 0 is still present in the tree. Like other properties on the Visual, Opacity can be animated using the Windows,UI.Composition animation system.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Opacity.

(Inherited from Visual)

A quaternion describing an orientation and rotation in 3D space that will be applied to the visual. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Orientation.

(Inherited from Visual)

The parent of the visual.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Parent.

(Inherited from Visual)

Visual specifying the coordinate system in which this visual is composed.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.ParentForTransform.

(Inherited from Visual)

The collection of properties associated with the CompositionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.Properties.

(Inherited from CompositionObject)

Specifies the offset of the visual with respect to the size of its parent visual.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.RelativeOffsetAdjustment.

(Inherited from Visual)

Gets or sets the size of the visual with respect to the size of its parent visual.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.RelativeSizeAdjustment.

(Inherited from Visual)

The rotation angle in radians of the visual. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.RotationAngle.

(Inherited from Visual)

The rotation angle of the visual in degrees. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.RotationAngleInDegrees.

(Inherited from Visual)

The axis to rotate the visual around. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.RotationAxis.

(Inherited from Visual)

The scale to apply to the visual.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Scale.

(Inherited from Visual)

The width and height of the visual. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.Size.

(Inherited from Visual)

The transformation matrix to apply to the visual. Animatable.

Equivalent WinUI property: Microsoft.UI.Composition.Visual.TransformMatrix.

(Inherited from Visual)



Closes the CompositionObject and releases system resources.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.Close.

(Inherited from CompositionObject)
ConnectAnimation(String, CompositionAnimation)

Connects and animation.

(Inherited from CompositionObject)

Disconnects an animation.

(Inherited from CompositionObject)

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from CompositionObject)
PopulatePropertyInfo(String, AnimationPropertyInfo)

Defines a property that can be animated.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.PopulatePropertyInfo.

(Inherited from CompositionObject)
StartAnimation(String, CompositionAnimation)

Connects an animation with the specified property of the object and starts the animation.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StartAnimation.

(Inherited from CompositionObject)

Starts an animation group.

The StartAnimationGroup method on CompositionObject lets you start CompositionAnimationGroup. All the animations in the group will be started at the same time on the object.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StartAnimationGroup.

(Inherited from CompositionObject)

Disconnects an animation from the specified property and stops the animation.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StopAnimation.

(Inherited from CompositionObject)

Stops an animation group.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StopAnimationGroup.

(Inherited from CompositionObject)

Returns an AnimationController for the animation running on the specified property.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.TryGetAnimationController.

(Inherited from CompositionObject)

Applies to

See also