Export (0) Print
Expand All

Viewport3D.Camera Property

Gets or sets a camera object that projects the 3-D contents of the Viewport3D to the 2-D surface of the Viewport3D.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public Camera Camera { get; set; }

Property Value

Type: System.Windows.Media.Media3D.Camera
The camera that projects the 3-D contents to the 2-D surface.

Identifier field

CameraProperty

Metadata properties set to true

None

NoteNote

The metadata type on this dependency property is PropertyMetadata, not FrameworkPropertyMetadata.

This property represents the viewing projection of the 3-D scene.

The following example shows setting the Camera property of a Viewport3D using code. To see the entirety of the code from which this excerpt was taken, see How to: Create a 3-D Scene.

// Defines the camera used to view the 3D object. In order to view the 3D object, 
// the camera must be positioned and pointed such that the object is within view  
// of the camera.
PerspectiveCamera myPCamera = new PerspectiveCamera();

// Specify where in the 3D scene the camera is.
myPCamera.Position = new Point3D(0, 0, 2);

// Specify the direction that the camera is pointing.
myPCamera.LookDirection = new Vector3D(0, 0, -1);

// Define camera's horizontal field of view in degrees.
myPCamera.FieldOfView = 60;

// Asign the camera to the viewport
myViewport3D.Camera = myPCamera;

The following example shows setting the Camera property of a Viewport3D using Extensible Application Markup Language (XAML). To see the entirety of the code from which this excerpt was taken, see How to: Create a 3-D Scene.

			<!-- Add a camera. -->
			<Viewport3D.Camera>
				<PerspectiveCamera FarPlaneDistance="20" LookDirection="5,-2,-3" UpDirection="0,1,0" NearPlaneDistance="1" Position="-5,2,3" FieldOfView="45" />
			</Viewport3D.Camera>

More Code

How to: Create a 3-D SceneThis example shows how to create a 3-D object that looks like a flat sheet of paper which has been rotated. A Viewport3D along with the following components are used to create this simple 3-D scene:

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft