This topic has not yet been rated - Rate this topic

RayHitTestParameters.Direction Property

Gets or sets a Vector3D that indicates the direction (from its origin) of the ray along which to hit test.

Namespace:  System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)
public Vector3D Direction { get; }

Property Value

Type: System.Windows.Media.Media3D.Vector3D
Vector3D that indicates the direction of the ray along which to hit test.

Note that the visual layer supports hit testing against all objects under a point or geometry, not just the topmost object. A 2D hit test will also return 3D results directly under the specified point or geometry.


public void HitTest(object sender, System.Windows.Input.MouseButtonEventArgs args)
{
    Point mouseposition = args.GetPosition(myViewport);
    Point3D testpoint3D = new Point3D(mouseposition.X, mouseposition.Y, 0);
    Vector3D testdirection = new Vector3D(mouseposition.X, mouseposition.Y, 10);
    PointHitTestParameters pointparams = new PointHitTestParameters(mouseposition);
    RayHitTestParameters rayparams = new RayHitTestParameters(testpoint3D, testdirection);

    //test for a result in the Viewport3D
    VisualTreeHelper.HitTest(myViewport, null, HTResult, pointparams);


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.