This documentation is archived and is not being maintained.

ContainerUIElement3D Class

Represents a container for Visual3D objects.

Namespace:  System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)

<ContentPropertyAttribute("Children")> _
Public NotInheritable Class ContainerUIElement3D _
	Inherits UIElement3D
Dim instance As ContainerUIElement3D

Content Model: ContainerUIElement3D enforces a strong content model for child content. The Children collection of a ContainerUIElement3D element can only consist of UIElement3D objects. Adding a UIElement3D child to a ContainerUIElement3D implicitly adds it to the Visual3DCollection for the ContainerUIElement3D element.

ContainerUIElement3D does not have a visual representation; it serves as a container for other visual 3-D objects. ContainerUIElement3D is a UIElement3D object, which provides support for input, focus, and events in 3-D.

This class does not set the Visual3DModel property.

ContainerUIElement3D is introduced in the .NET Framework version 3.5. For more information, see .NET Framework 3.5 Architecture.

In the following example, the ContainerUIElement3D object contains two cubes as its children:

        <PerspectiveCamera Position="8,3,0" LookDirection="-8,-3,0" />

    <!-- The container has the two cubes as its children -->
    <ContainerUIElement3D MouseDown="ContainerMouseDown">
                    <AxisAngleRotation3D x:Name="containerRotation" Axis="0, 1, 0" Angle="0" />

        <!-- Cube 1 -->
        <ModelUIElement3D MouseDown="Cube1MouseDown">
                <TranslateTransform3D OffsetZ="1.5" />

                <GeometryModel3D Geometry="{StaticResource CubeMesh}">
                        <DiffuseMaterial x:Name="cube1Material" Brush="Blue" />

        <!-- Cube 2 -->
        <ModelUIElement3D MouseDown="Cube2MouseDown">
                <TranslateTransform3D OffsetZ="-1.5" />

                <GeometryModel3D Geometry="{StaticResource CubeMesh}">
                        <DiffuseMaterial x:Name="cube2Material" Brush="Green" />

    <!-- Lights -->
            <PointLight Color="White" Position="3, 10, 4" />

The following shows the event handler of the container:

// When the ContainerUIElement3D that has the two cubes as its children gets the 
// routed click event, spin the cubes in a 360 degree circle 
private void ContainerMouseDown(object sender, MouseButtonEventArgs e)
    e.Handled = true;

    // spin the cubes around
    DoubleAnimation doubleAnimation = new DoubleAnimation(0, 
                                                          new Duration(TimeSpan.FromSeconds(0.5)));
    containerRotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, doubleAnimation);

For the complete sample, see Handling Events in 3-D Sample.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1, 3.0 SP1