【发布时间】:2011-11-26 21:08:42
【问题描述】:
我找到了一些与 WPF 相关的示例,但没有找到与 Silverlight 相关的示例。
那么,在代码中设置Microsoft.Expression.Interactivity.Core.DataTrigger 的工作示例是什么?
这是我目前拥有的代码,虽然它不起作用(没有例外,但在运行时没有任何反应):
// Set up a storyboard
var duration = new Duration(TimeSpan.FromMilliseconds(400));
var animation = new ColorAnimation
{
To = Colors.White,
RepeatBehavior = RepeatBehavior.Forever,
AutoReverse = true,
Duration = duration
};
var sb = new Storyboard
{
RepeatBehavior = RepeatBehavior.Forever,
AutoReverse = true,
Duration = duration
};
sb.Children.Add(animation);
Storyboard.SetTarget(animation, fillBrush);
Storyboard.SetTargetProperty(animation, new PropertyPath("(SolidColorBrush.Color)"));
// Configure the data trigger
var focusTrigger = new DataTrigger
{
Binding = new Binding("IsFocussed")
{
Source = asset,
Mode = BindingMode.OneWay
},
Value = true
};
focusTrigger.Actions.Add(new ControlStoryboardAction
{
Storyboard = sb,
ControlStoryboardOption = ControlStoryboardOption.Play,
IsEnabled = true
});
asset.IsFocussed 更改并通过INotifyPropertyChanged 发出更改通知。
【问题讨论】:
-
查看调试输出,看起来您的绑定不正确:'IsFocused'。也许双“s”在这里是个问题?
-
@invisible -- 谢谢,但这次不是这样 :)
标签: c# .net silverlight datatrigger