RayHitTestParameters.Direction 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定 Vector3D,指定沿著其路徑進行點擊測試之射線的方向 (從其原點開始)。
public:
property System::Windows::Media::Media3D::Vector3D Direction { System::Windows::Media::Media3D::Vector3D get(); };
public System.Windows.Media.Media3D.Vector3D Direction { get; }
member this.Direction : System.Windows.Media.Media3D.Vector3D
Public ReadOnly Property Direction As Vector3D
屬性值
指出沿著其路徑進行點擊測試之射線方向的 Vector3D。
範例
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);
Public Sub HitTest(ByVal sender As Object, ByVal args As MouseButtonEventArgs)
Dim mouseposition As Point = args.GetPosition(myViewport)
Dim testpoint3D As New Point3D(mouseposition.X, mouseposition.Y, 0)
Dim testdirection As New Vector3D(mouseposition.X, mouseposition.Y, 10)
Dim pointparams As New PointHitTestParameters(mouseposition)
Dim rayparams As New RayHitTestParameters(testpoint3D, testdirection)
'test for a result in the Viewport3D
VisualTreeHelper.HitTest(myViewport, Nothing, AddressOf HTResult, pointparams)
備註
請注意,視覺層支援對點或幾何下的所有物件進行點擊測試,而不只是最上層的物件。 2D 點擊測試也會直接在指定的點或幾何底下傳回 3D 結果。