ContainerVisual.HitTest メソッド

定義

ヒット テストの最上位のビジュアル オブジェクトを返します。

オーバーロード

HitTest(Point)

Point を指定して、ヒット テストの最上位のビジュアル オブジェクトを返します。

HitTest(HitTestFilterCallback, HitTestResultCallback, HitTestParameters)

HitTestFilterCallback オブジェクトと HitTestResultCallback オブジェクトを使用して、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 型として返されたビジュアルのヒット テスト結果。

次の例は、 メソッドから戻り値を取得する HitTestResult 方法を HitTest 示しています。

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

HitTestFilterCallback オブジェクトと HitTestResultCallback オブジェクトを使用して、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呼び出されます。

適用対象