【发布时间】:2011-04-27 17:00:41
【问题描述】:
这是我昨天here 发布的问题的后续。使用 H.B. 发布的 code-sn-p 绑定到图标有效,但我似乎无法弄清楚如何向其添加触发条件,以便在鼠标悬停时显示不同的图标。当前代码如下所示:
xmlns:res="clr-namespace:MyProject.Resources"
xmlns:Helpers="clr-namespace:MyProject.Converters"
...
<Image Name="imgMin"
Grid.Column="0"
Stretch="UniformToFill"
Cursor="Hand"
MouseDown="imgMin_MouseDown">
<Image.Source>
<Binding Source="{x:Static res:AppResources.minimize}">
<Binding.Converter>
<Helpers:IconToImageSourceConverter/>
</Binding.Converter>
</Binding>
</Image.Source>
</Image>
我需要在此处更改什么以便在鼠标悬停时显示不同的图标 (res:AppResources.minimize_glow)?我尝试在某处弄乱触发器,但 Image.Source 不接受另一个孩子,Binding 不支持直接内容,将 Image.Source 更改为 Image.Style 不起作用,因为 Style 不能包含 Binding.. . 我的想法已经不多了,我的 Google-fu 也没有想出任何有用的东西。此外,即使我可以让触发器使用它,将一个绑定到突出显示的图标放入触发器可能是我的下一个头痛。必须有办法做到这一点,对吧?
【问题讨论】:
标签: c# .net wpf triggers binding