【问题标题】:Can't assign RoutedEvent to Binding.TargetUpdated无法将 RoutedEvent 分配给 Binding.TargetUpdated
【发布时间】:2011-11-25 12:38:48
【问题描述】:

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

 <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">

这段代码有什么问题?

【问题讨论】:

    标签: silverlight data-binding silverlight-4.0 storyboard


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-30
      • 2021-06-21
      • 2013-02-11
      相关资源
      最近更新 更多