HitTestResult HitTestResult HitTestResult HitTestResult Class

定義

提供數個衍生類別的基底類別,這個類別表示點擊測試的傳回值。Provides the base class for several derived classes that represents the return value from a hit test.

public ref class HitTestResult abstract
public abstract class HitTestResult
type HitTestResult = class
Public MustInherit Class HitTestResult
繼承
HitTestResultHitTestResultHitTestResultHitTestResult
衍生

範例

下列範例示範如何HitTestResult HitTest從方法中取出傳回值。The following example shows how to retrieve the HitTestResult return value from the HitTest method.

// 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

備註

、和類別衍生自HitTestResultPointHitTestResult GeometryHitTestResult RayHitTestResultThe PointHitTestResult, GeometryHitTestResult, and RayHitTestResult classes derive from HitTestResult.

屬性

VisualHit VisualHit VisualHit VisualHit

取得已點擊的視覺物件。Gets the visual object that was hit.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱