更新:2007 年 11 月
命名空间:
System.Windows.Media.Media3D 程序集:
PresentationCore(在 PresentationCore.dll 中)
用于 XAML 的 XMLNS:http://schemas.microsoft.com/winfx/xaml/presentation
<ContentPropertyAttribute("Children")> _
Public NotInheritable Class ContainerUIElement3D _
Inherits UIElement3D
Dim instance As ContainerUIElement3D
[ContentPropertyAttribute("Children")]
public sealed class ContainerUIElement3D : UIElement3D
[ContentPropertyAttribute(L"Children")]
public ref class ContainerUIElement3D sealed : public UIElement3D
/** @attribute ContentPropertyAttribute("Children") */
public final class ContainerUIElement3D extends UIElement3D
public final class ContainerUIElement3D extends UIElement3D
<ContainerUIElement3D>
Children
</ContainerUIElement3D>
内容模型:ContainerUIElement3D 对子内容强制使用强内容模型。ContainerUIElement3D 元素的 Children 集合只能包含 UIElement3D 对象。将 UIElement3D 子级添加到 ContainerUIElement3D 会将该子级隐式添加到 ContainerUIElement3D 元素的 Visual3DCollection。
ContainerUIElement3D 没有可视化表示形式;它用作其他可视三维对象的容器。ContainerUIElement3D 是一个 UIElement3D 对象,该对象提供对三维中的输入、焦点和事件的支持。
此类不设置 Visual3DModel 属性。
ContainerUIElement3D 是在 .NET Framework 3.5 版中引入的。有关更多信息,请参见 .NET Framework 3.5 体系结构。
在下面的示例中,ContainerUIElement3D 对象包含两个多维数据集作为自己的子级:
<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>
下面显示容器的事件处理程序:
// 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);
}
有关完整示例,请参见处理三维事件的示例。
System..::.Object
System.Windows.Threading..::.DispatcherObject
System.Windows..::.DependencyObject
System.Windows.Media.Media3D..::.Visual3D
System.Windows..::.UIElement3D
System.Windows.Media.Media3D..::.ContainerUIElement3D
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5 SP1、3.0 SP1
参考
其他资源