The fill is part of what specifies the hit test area of your controls. In WPF controls generally do a pixel-perfect hit test, not a rectangular one. For example, if you put an <Ellipse/>
in you XAML, clicking outside of the circumference, but inside the bounding rectangle won't generate a MouseDown event in the Ellipse (this one is kind of obvious though). In the same way not specifying a Fill for a Shape means that the inside of the shape simply doesn't exist - it hit tests negatively and lets clicks fall through. In other words, shapes without a Fill only constitute of their outline for purposes of hit testing.
If you want to have a border-only transparent rectangle (or any other Shape
) that still hit tests on the inside, then specify Fill="Transparent"
.
This is true not only for shapes, but also for containers like Grid
and Border
- if you don't specify a Background
, then their empty area doesn't register in hit testing.