ContainerVisual.HitTest Metoda

Definicja

Zwracanie najbardziej najbardziej wizualnego obiektu testu trafienia.

Przeciążenia

HitTest(Point)

Zwraca najbardziej najbardziej wizualny obiekt testu trafienia, określając Pointobiekt .

HitTest(HitTestFilterCallback, HitTestResultCallback, HitTestParameters)

Inicjuje test trafienia na obiekcie ContainerVisual przy użyciu HitTestFilterCallback obiektów i HitTestResultCallback .

HitTest(Point)

Zwraca najbardziej najbardziej wizualny obiekt testu trafienia, określając Pointobiekt .

public:
 System::Windows::Media::HitTestResult ^ HitTest(System::Windows::Point point);
public System.Windows.Media.HitTestResult HitTest (System.Windows.Point point);
override this.HitTest : System.Windows.Point -> System.Windows.Media.HitTestResult
member this.HitTest : System.Windows.Point -> System.Windows.Media.HitTestResult
Public Function HitTest (point As Point) As HitTestResult

Parametry

point
Point

Wartość punktu do trafienia testu.

Zwraca

Wynik testu trafień wizualizacji zwrócony jako HitTestResult typ.

Przykłady

W poniższym przykładzie pokazano, jak pobrać wartość zwracaną HitTestResultHitTest z metody .

// Capture the mouse event and hit test the coordinate point value against
// the child visual objects.
void MyVisualHost_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    // Retrieve the coordinates of the mouse button event.
    Point pt = e.GetPosition((UIElement)sender);

    // Initiate the hit test on the ContainerVisual's visual tree.
    HitTestResult result = _containerVisual.HitTest(pt);

    // Perform the action on the hit visual.
    if (result.VisualHit != null)
    {
        ProcessHitVisual((Visual)result.VisualHit);
    }
}
' Capture the mouse event and hit test the coordinate point value against
' the child visual objects.
Private Sub MyVisualHost_MouseLeftButtonUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
    ' Retrieve the coordinates of the mouse button event.
    Dim pt As Point = e.GetPosition(CType(sender, UIElement))

    ' Initiate the hit test on the ContainerVisual's visual tree.
    Dim result As HitTestResult = _containerVisual.HitTest(pt)

    ' Perform the action on the hit visual.
    If result.VisualHit IsNot Nothing Then
        ProcessHitVisual(CType(result.VisualHit, Visual))
    End If
End Sub

Uwagi

Właściwość VisualHit wartości zwracanej reprezentuje Visual obiekt, który został trafiony.

Dotyczy

HitTest(HitTestFilterCallback, HitTestResultCallback, HitTestParameters)

Inicjuje test trafienia na obiekcie ContainerVisual przy użyciu HitTestFilterCallback obiektów i HitTestResultCallback .

public:
 void HitTest(System::Windows::Media::HitTestFilterCallback ^ filterCallback, System::Windows::Media::HitTestResultCallback ^ resultCallback, System::Windows::Media::HitTestParameters ^ hitTestParameters);
public void HitTest (System.Windows.Media.HitTestFilterCallback filterCallback, System.Windows.Media.HitTestResultCallback resultCallback, System.Windows.Media.HitTestParameters hitTestParameters);
override this.HitTest : System.Windows.Media.HitTestFilterCallback * System.Windows.Media.HitTestResultCallback * System.Windows.Media.HitTestParameters -> unit
member this.HitTest : System.Windows.Media.HitTestFilterCallback * System.Windows.Media.HitTestResultCallback * System.Windows.Media.HitTestParameters -> unit
Public Sub HitTest (filterCallback As HitTestFilterCallback, resultCallback As HitTestResultCallback, hitTestParameters As HitTestParameters)

Parametry

filterCallback
HitTestFilterCallback

Delegat, który umożliwia ignorowanie części drzewa wizualnego, które nie są zainteresowane przetwarzaniem wyników testu trafień.

resultCallback
HitTestResultCallback

Delegat służący do kontrolowania powrotu informacji o teście trafień.

hitTestParameters
HitTestParameters

Definiuje zestaw parametrów dla testu trafienia.

Uwagi

Parametr filterCallback może mieć wartość null, w tym przypadku jest ignorowany. Jeśli filterCallback parametr nie nulljest , jest wywoływany przed .resultCallback

Dotyczy