HitTestResult Classe

Definizione

Fornisce la classe base per diverse classi derivate che rappresenta il valore restituito da un hit test.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
Ereditarietà
HitTestResult
Derivato

Esempi

Nell'esempio seguente viene illustrato come recuperare il HitTestResult valore restituito HitTest dal metodo.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

Commenti

Le PointHitTestResultclassi GeometryHitTestResult, HitTestResulte RayHitTestResult derivano da.The PointHitTestResult, GeometryHitTestResult, and RayHitTestResult classes derive from HitTestResult.

Proprietà

VisualHit

Ottiene l'oggetto visivo raggiunto.Gets the visual object that was hit.

Metodi

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Ereditato da Object)

Si applica a

Vedi anche