1
我有一個按鈕樣式模板+如下:與自定義模板WPF按鈕只能被壓在內容
<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" />
然而,按鈕只能在鼠標移過路徑時按下,而不能在整個按鈕上按下。當鼠標在按鈕上但不在路徑上時,如何獲取按鈕?