Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF hit testing UserControl and geometry
    text
    copied!<p>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.</p> <pre><code>Protected Overrides Function HitTestCore(hitTestParameters As System.Windows.Media.PointHitTestParameters) As System.Windows.Media.HitTestResult Return New PointHitTestResult(Me, hitTestParameters.HitPoint) End Function </code></pre> <p>I also have a filter which correctly shows the controls I want to hit-test somehow the <code>htcallback</code> isn't working.</p> <p>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.</p> <pre><code>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)) </code></pre> <p>I based my answer on this third reply. <a href="https://stackoverflow.com/questions/3411910/problem-with-visualtreehelper-hittest-in-wpf/7162443#7162443">Problem with VisualTreeHelper.HitTest in WPF</a></p> <p>What does he mean with this </p> <blockquote> <p><em>if you want to hit-test against geometry you need to override that second overload as well</em></p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload