无法将RoutedEvent分配给Binding.TargetUpdated

时间:2011-11-25 12:38:49

标签: silverlight data-binding silverlight-4.0 storyboard

我有一个文本块,应该对更改文本做出反应(它必须显示文本几秒钟,然后消失)。

 <TextBlock Text="{Binding Path=OperationMessage, NotifyOnValidationError=True}" x:Name="label_OperationMessage" Visibility="Collapsed" HorizontalAlignment="Right" Margin="3,3,3,3" >
                 <TextBlock.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0" To="1.0" />
<DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:2" From="1.0" To="0.0" BeginTime="0:0:5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
            </TextBlock>

当我启动我的应用时,我收到错误:

Failed to assign to property 'System.Windows.EventTrigger.RoutedEvent'. 

就行了

<EventTrigger RoutedEvent="Binding.TargetUpdated">

此代码有什么问题?

1 个答案:

答案 0 :(得分:1)

Silverlight支持在Triggers属性中使用的唯一事件是Loaded事件。其他任何事都会导致此例外。

为了实现这种Xaml事件逻辑,您可以下载包含各种有用功能的Blend SDK。在您的情况下,您正在寻找PropertyChangedTrigger