我正在尝试制作一个播放器(某种)控件。我有一个按钮的用户控件已经可用(公司控件)。我试图给我的按钮我添加到其内容中的图像的形状。
问题是当我删除模板样式(这是为了根据图像边界适合我的按钮边界)时,当我尝试单击按钮时,我无法触发关联的 ToolBarCommand。本质上,我无法单击按钮本身。
凝视这并没有多大帮助,我试图对IsHitTestVisible="False"
图像 - 但这也没有帮助。
以下是我的代码:
<my:NewButton Command="{Binding ToolBarCommand}" CommandParameter="Play">
<my:NewButton.Style>
<Style>
<Setter Property="my:NewButton.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type my:NewButton}">
<ContentPresenter HorizontalAlignment=" TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</my:NewButton.Style>
<my:NewButton.Content>
<Image Source="{Binding PlayState}" IsHitTestVisible="False" />
</my:NewButton.Content>
</my:NewButton>
任何帮助深表感谢。PS:VS2012,.net 4.0