WPF: Making the entire "block" of a path clickable
c#, path, wpf
Solution
Aviad P. is correct. This is what I do:
<Border Background="Transparent">
<Path ... />
</Border>
This works because when "hit testing" to determine where a mouse click should be routed, the "Transparent" brush is considered as if it was a regular color.
Problem
I have a special `ControlTemplate` for some of my `Button`s. ``` <ControlTemplate TargetType="{x:Type Button}"> <Path Name="ThePath" Fill="White" Stretch="UniformToFill" Width="12" Height="12" Stroke="White" StrokeThickness="4" Data="M1.5,1.5 L10.5,10.5 M1.5,10.5 L10.5,1.5"/> <ControlTemplate.Triggers> <Trigger Property="IsFocused" Value="True"> <Setter Property="Fill" Value="#afa" TargetName="ThePath"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> ``` This works fine, but since I'm using a `Path` (in this case, it's just shaped like a fat X), exactly the path is clickable, not the small space between the corners of the X. Is there any automagic thing I can use to make the entire "block" of the X clickable? I've considered wrapping the path in a rectangular object, but I'd just like to make sure I'm not missing something trivial.