visual-studiouwppolygonblend

UWP - Custom non-rectangular hit area on button. Either image or shape


I would like to define a non-rectangular clickable "hit area" for a button. I am happy to define this custom shape using a UWP XAML path, or by using a PNG with transparent areas.

The following question explains how to use an XAML path for a button's appearance, but the result still seems to use a rectangular bounding box hit area. XAML UWP Button with a polygonal shape

There are also posts explaining how to override the Image class, intercepting the 'click' event, and determining the opacity of the pixels under the mouse cursor. This would solve my problem, but this solution only applies to WPF.

Does anyone know of a solution for UWP?


Solution

  • It looks like I can just use the raw < path > element, and use its pointer events directly.