This documentation is archived and is not being maintained.
ModelUIElement3D Class
Visual Studio 2008
Renders a 3-D model that supports input, focus, and events.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
ModelUIElement3D is introduced in the .NET Framework version 3.5. For more information, see .NET Framework 3.5 Architecture.
The following example shows how to create two cubes using the ModelUIElement3D class:
<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 cubes respond to the mouse down event through the following event handlers:
For the complete sample, see Handling Events in 3-D Sample.
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Media3D.Visual3D
System.Windows.UIElement3D
System.Windows.Media.Media3D.ModelUIElement3D
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Media3D.Visual3D
System.Windows.UIElement3D
System.Windows.Media.Media3D.ModelUIElement3D
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.
Show: