我有一个按钮样式+模板如下:
<Style x:Key="ButtonStyle" TargetType="RepeatButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="{DynamicResource {x:Static SystemColors.ControlColor}}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Path Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}">
<Path.Fill>
<SolidColorBrush x:Name="PathBrush" Color="{x:Static SystemColors.ControlDarkColor}" />
</Path.Fill>
</Path>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
该按钮的使用方式如下:
<RepeatButton Style="{StaticResource ButtonStyle}" Content="M 0 4 L 8 4 L 4 0 Z" />
但是,只有当鼠标在路径上时才能按下按钮,而不是在整个按钮上。当鼠标在按钮上但不在路径上时,如何让按钮被按下?