다음을 통해 공유


ContainerVisual.HitTest 메서드

정의

적중 테스트의 최상위 시각적 개체를 반환합니다.

오버로드

Name Description
HitTest(Point)

를 지정하여 적중 횟수 테스트의 가장 큰 시각적 개체를 Point반환합니다.

HitTest(HitTestFilterCallback, HitTestResultCallback, HitTestParameters)

HitTestResultCallback 개체를 사용하여 HitTestFilterCallback 적중 테스트를 ContainerVisual 시작합니다.

HitTest(Point)

를 지정하여 적중 횟수 테스트의 가장 큰 시각적 개체를 Point반환합니다.

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

매개 변수

point
Point

적중 테스트에 도달할 지점 값입니다.

반품

형식으로 반환된 시각적 개체의 적중 테스트 결과입니다 HitTestResult .

예제

다음 예제에서는 메서드에서 HitTest 반환 값을 검색 HitTestResult 하는 방법을 보여줍니다.

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

설명

반환 값의 속성은 VisualHit 적중된 개체를 Visual 나타냅니다.

적용 대상

HitTest(HitTestFilterCallback, HitTestResultCallback, HitTestParameters)

HitTestResultCallback 개체를 사용하여 HitTestFilterCallback 적중 테스트를 ContainerVisual 시작합니다.

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)

매개 변수

filterCallback
HitTestFilterCallback

적중 테스트 결과에서 처리에 관심이 없는 시각적 트리의 일부를 무시할 수 있는 대리자입니다.

resultCallback
HitTestResultCallback

적중 테스트 정보의 반환을 제어하는 데 사용되는 대리자입니다.

hitTestParameters
HitTestParameters

적중 테스트에 대한 매개 변수 집합을 정의합니다.

설명

매개 변수는 filterCallback null일 수 있으며, 이 경우 무시됩니다. 그렇지 않은 null경우 filterCallback 앞에 resultCallback호출됩니다.

적용 대상