Reputation: 1018
I'm trying to make hit testing work between one user control and another user control. I was looking at other questions and found that I have to put this in my user control.
Protected Overrides Function HitTestCore(hitTestParameters As System.Windows.Media.PointHitTestParameters) As System.Windows.Media.HitTestResult
Return New PointHitTestResult(Me, hitTestParameters.HitPoint)
End Function
I also have a filter which correctly shows the controls I want to hit-test somehow the htcallback
isn't working.
Because I can't hit-test with my user control, I made a rectangle on the same spot and use that in my hit test. This doesn't seem to be working.
Dim hitTestGeometry = New RectangleGeometry()
hitTestGeometry.Rect = New Rect(_selected.breedte, _selected.hoogte, Canvas.GetLeft(_selected), Canvas.GetTop(_selected))
Dim pt As New Point
VisualTreeHelper.HitTest(WorkFlowCanvas, New HitTestFilterCallback(AddressOf wcFilter), New HitTestResultCallback(AddressOf verplaatsing), New GeometryHitTestParameters(hitTestGeometry))
I based my answer on this third reply. Problem with VisualTreeHelper.HitTest in WPF
What does he mean with this
if you want to hit-test against geometry you need to override that second overload as well
Upvotes: 1
Views: 848
Reputation: 128013
Besides HitTestCore with a PointHitTestParameters
argument there is a second method HitTestCore with a GeometryHitTestParameters
argument.
This second one is called when you are hit-testing against a geometry.
Upvotes: 2