【发布时间】:2013-03-08 13:59:39
【问题描述】:
我有一个按钮样式+模板如下:
<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" />
但是,只有当鼠标悬停在路径上时才能按下按钮,而不是整个按钮。当鼠标在按钮上但不在路径上时,如何让按钮被按下?
【问题讨论】: