【发布时间】:2011-08-26 00:09:22
【问题描述】:
我创建了一个名为 ImageButton 的用户控件,并且我在 MouseOver 上使用 DropShadowEffect 将按钮显示为“活动”。但是,我似乎无法绑定 DropShadowEffect 的 Color 属性。谁能建议为什么这不起作用?
XAML;
<ControlTemplate x:Key="ActiveEffectTemplate" TargetType="{x:Type Controls:ImageButton}">
<Image Name="image" Source="{TemplateBinding ImageSource}">
<Image.Effect>
<DropShadowEffect
Color="{Binding HighlightColour}"
BlurRadius="20"
ShadowDepth="0"
Opacity="1"
Direction="0"/>
</Image.Effect>
</Image>
</ControlTemplate>
代码隐藏;
public static readonly DependencyProperty HighlightColourProperty =
DependencyProperty.Register("HighlightColour", typeof(Color), typeof(ImageButton));
public Color HighlightColour
{
get { return (Color)GetValue(HighlightColourProperty); }
set { SetValue(HighlightColourProperty, value); }
}
【问题讨论】:
标签: c# wpf xaml data-binding effects