PointHitTestResult 類別

定義

表示點擊測試的結果,這個點擊測試將 Point 做為點擊測試參數。

public ref class PointHitTestResult : System::Windows::Media::HitTestResult
public class PointHitTestResult : System.Windows.Media.HitTestResult
type PointHitTestResult = class
    inherit HitTestResult
Public Class PointHitTestResult
Inherits HitTestResult
繼承
PointHitTestResult
衍生

範例

下列範例示範如何從 HitTest 方法擷取 PointHitTestResult 傳回值。

// Respond to the left mouse button down event by initiating the hit test.
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    // Retrieve the coordinate of the mouse position.
    Point pt = e.GetPosition((UIElement)sender);

    // Perform the hit test against a given portion of the visual object tree.
    HitTestResult result = VisualTreeHelper.HitTest(myCanvas, pt);

    if (result != null)
    {
        // Perform action on hit visual object.
    }
}
' Respond to the left mouse button down event by initiating the hit test.
Private Overloads Sub OnMouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    ' Retrieve the coordinate of the mouse position.
    Dim pt As Point = e.GetPosition(CType(sender, UIElement))

    ' Perform the hit test against a given portion of the visual object tree.
    Dim result As HitTestResult = VisualTreeHelper.HitTest(myCanvas, pt)

    If result IsNot Nothing Then
        ' Perform action on hit visual object.
    End If
End Sub

備註

您也可以使用 Geometry 做為點擊測試參數,並將結果 GeometryHitTestResult 傳回為 ,在視覺物件上執行點擊測試。 如需詳細資訊,請參閱 How to: Hit Test Using Geometry as a Parameter

建構函式

PointHitTestResult(Visual, Point)

初始化 PointHitTestResult 類別的新執行個體。

屬性

PointHit

取得從點擊測試結果傳回的點值。

VisualHit

取得從點擊測試結果傳回的視覺物件。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於