首页 > 解决方案 > 动画后的属性访问

问题描述

我有动画代码。

<TextBlock Grid.Row="1" VerticalAlignment="Top" FontSize="14"
                       Foreground="{Binding TextFill, Mode=OneWay}"
                       Text="{Binding Info, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                       hlprs:AnimatableTextHelper.ProtectionProperty="{Binding ToogleButtonIsChecked, Mode=OneWay, NotifyOnTargetUpdated=True}" TargetUpdated="TextBlock_TargetUpdated"/> 

TextBlock_TargetUpdated:

ColorAnimation animation = new ColorAnimation(Colors.Green, new Duration(TimeSpan.FromMilliseconds(1300)));
                animation.Completed += (s, e_) =>
                {
                    tmpSender.Foreground.BeginAnimation(SolidColorBrush.ColorProperty, null);

                    var b = tmpSender.GetBindingExpression(TextBlock.ForegroundProperty);
                }; 
                animation.FillBehavior = FillBehavior.Stop;
                tmpSender.Foreground.BeginAnimation(SolidColorBrush.ColorProperty, animation);

动画后我无法通过绑定和更新属性b == null。我希望属性从 dataconttext 请求当前值

我究竟做错了什么?

标签: .netwpf

解决方案


推荐阅读