I am using the VisualTreeHelper
to perform a HitTest
on a button that looks like this...
<Button Width="100"
Height="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Purple">
Hello world
</Button>
However when I perform the actual HitTest as such:
HitTestResult result = VisualTreeHelper.HitTest(_ContentHolder, new Point(xTransform, yTransform));
if (result != null)
{
}
The returned object looks like this VisualHit = {System.Windows.Controls.Border}
which doesn't quite make sense to me.
Could anyone please provide any guidance as to what I might be doing wrong, how I would return the actual Button object (such that I can trigger any event handlers) and why I may be experiencing such behaviour?