Problem with VisualTreeHelper.HitTest in WPF -


I am trying to kill a bunch of UserControls on the canvas. I do not want to hit the hit test () through the visual tree completely, so I'm using filter callback to make sure that I'm only hit-testing usercontrol.

My problem is that UserControl never hits, it should, but it is not. If I use filterbackbacks, then I come back that it does not hit anything if I let the hit test run through the visual tree, it leaves the user chart.

Here are some code:

  & lt; Canvas X: Name = "Container" & gt; & Lt; UserControl & gt; & Lt; Grid & gt; & Lt; Rectangle / & gt; & Lt; / Grid & gt; & Lt; / UserControl & gt; & Lt; UserControl & gt; & Lt; Grid & gt; & Lt; Rectangle / & gt; & Lt; / Grid & gt; & Lt; / UserControl & gt; & Lt; / Canvas & gt; ... VisualTreeHelper.HitTest (Container, OnFilter, OnResult, MyPoint); ... Private Zero OnResult (dependent object o) {// I get a rectangle here but there is never a user control) Private Zero Effector (dependency object o) {// I control the user here, but even when I Compared to not having anything else, it will not trigger the Hit Hit scene. But child will be rectangle}  

I was not getting a user control of HitTest problem This is apparently done by () design.

I worked by handling the hit of some element inside user control and then finding the parent user control using the VisualTreeHelper.GetParent method. I am not very familiar with WPF yet, so I'm not sure that it would be better to use FrameworkElement.Parent property.

However, after finding some of its content elements by user control (or a visual hit test):

  Public Static Tee GETIVE PARTTER  

(This dependency object element) where T: Dependency object {while (element! = Blank & amp;! Element is T) element = VisualTreeHelper.GetParent (element); Return (t) element;}


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -