Quantcast
Viewing latest article 2
Browse Latest Browse All 5

HitTest Custom Control

What's your baseclass?

If your control doesn't have a visual in it's tree (even something you generate in OnRender) click will go straight through it.

If you derive from FrameworkElement, you need to either add a child visual that you measure/arrange or you can draw something.

Panel, for instance, does the following:

protectedoverridevoidOnRender(DrawingContext dc)
{Brushbrush1 = this.Background;if (brush1 != null)
      {dc.DrawRectangle(brush1, null, newRect(0, 0, base.RenderSize.Width, base.RenderSize.Height));
      }
}
A null background won't hit test, but a transparent background will.

 


Viewing latest article 2
Browse Latest Browse All 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>