テキストブロックのように動作するが、テキストが変更されるとアニメーションを実行するユーザー コントロールを作成しようとしています。このようなテキストブロックの作成には成功しましたが、この機能を独自のコントロールに埋め込むことはできません。これは私の現在の試みです:
<ItemsControl Name="_itemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ., NotifyOnTargetUpdated=True}">
<TextBlock.Background>
<SolidColorBrush x:Name="bgBrush"></SolidColorBrush>
</TextBlock.Background>
<TextBlock.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="bgBrush"
Storyboard.TargetProperty="Color" To="Red" Duration="0:0:.5"
AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
この answerに従って、コード ビハインドは単に Text 依存関係プロパティを宣言し、OnPropertyChanged イベントが送信されたときにコントロールの ItemsSource プロパティをこのプロパティに設定します。
このコントロールの Text プロパティをアプリケーション内の独自のプロパティにバインドすると、コンテンツの変更が適切に登録されますが、アニメーションは表示されません。ただし、上記のスニペットの Textblock をアプリケーションに貼り付けるだけで (もちろんバインディングを修正して)、アニメーションが表示されます。ここで何が欠けていますか?