ContainerUIElement3D Class

Represents a container for Visual3D objects.

Namespace:  System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

'Declaration
<ContentPropertyAttribute("Children")> _
Public NotInheritable Class ContainerUIElement3D _
	Inherits UIElement3D
'Usage
Dim instance As ContainerUIElement3D
<ContainerUIElement3D>
  Children
</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:

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

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

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

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

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

            <ModelUIElement3D.Model>
                <GeometryModel3D Geometry="{StaticResource CubeMesh}">
                    <GeometryModel3D.Material>
                        <DiffuseMaterial x:Name="cube2Material" Brush="Green" />
                    </GeometryModel3D.Material>
                </GeometryModel3D>
            </ModelUIElement3D.Model>
        </ModelUIElement3D>                
    </ContainerUIElement3D>

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

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, 
                                                          360,
                                                          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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft