Coloranimation-为默认颜色设置动画

时间:2019-06-05 23:53:32

标签: c# wpf animation colors

我正在通过触发器更改TextBlock的颜色,在5秒钟后,我想将颜色切换回资源字典中定义的TextBlock的初始默认颜色,而无需明确定义颜色。

这是我使用的TextBlock样式:

<Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="{x:Type TextBlock}">
    <Style.Triggers>
        <DataTrigger Binding="{Binding IsSelected}" Value="True">
            <Setter Property="Foreground" Value="{StaticResource LightBackgroundBrush}" />

            <!--  Go back to initial color  -->
            <DataTrigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <ColorAnimation
                            BeginTime="0:0:05"
                            Storyboard.TargetProperty="Foreground.Color"
                            To="???" />
                    </Storyboard>
                </BeginStoryboard>
            </DataTrigger.EnterActions>
        </DataTrigger>
    </Style.Triggers>
</Style>

我的意思是这行:

<ColorAnimation
   BeginTime="0:0:05"
   Storyboard.TargetProperty="Foreground.Color"
   To="???" />

我尝试将To属性设置为{x:Null}标记扩展,但是颜色保持不变。

如何使其设置为默认颜色的动画?


编辑

由于@Rekshino将此问题标记为可能重复,因此我想声明我的问题与他所链接的问题之间没有关系,因此,由于我没有问过{{ 1}}属性绑定。

0 个答案:

没有答案