我正在尝试设置一个按钮,这样当按钮启用而不是鼠标悬停时它会显示默认图像,当启用按钮并且鼠标悬停时它显示不同的图像,当它被禁用时(无论鼠标悬停)它显示第三张图片。
我尝试按照此answer进行操作,但是当我运行程序时,出现Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '47' and line position '45'.
错误,该错误等同于下面代码段中<---
标识的行:
<!-- Edit Button using edit.png (pencil) -->
<Style x:Key="PencilEditEnabledButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border HorizontalAlignment="Center"
VerticalAlignment="Center">
<!-- default image -->
<Image x:Name="ButtonImage"
Source="/myLibrary;component/Resources/edit.png"
Height="20"/>
</Border>
<ControlTemplate.Triggers>
<!-- update image on mouseover -->
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="ButtonImage"
Property="Source"
Value="/myLibrary;component/Resources/edit_mouseover.png" />
</Trigger>
<!-- update image when button is disabled -->
<Trigger Property="IsEnabled" Value="true">
<Setter TargetName="ButtonImage" <---
Property="Source"
Value="/myLibrary;component/Resources/edit_disabled.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
这是否可行,如果是,我如何更正Style
。
答案 0 :(得分:0)
您是否已将“资源”文件夹包含在项目中?