gpt4 book ai didi

wpf - 在 Xaml 中控制 WPF 动画

转载 作者:行者123 更新时间:2023-12-03 02:26:24 25 4
gpt4 key购买 nike

我定义了 2 个动画来闪烁网格中的单元格值,一种是当值增加时,另一种是当值减少时。

在调试中运行应用程序时,我在输出窗口中看到大量警告,内容如下:-

Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='Stop'; Storyboard='System.Windows.Media.Animation.Storyboard';

我的动画是通过数据触发器触发的,如下所示:-

enter image description here

Storyboard如下:

enter image description here

鉴于 StopStoryboard 似乎是问题所在,即没有正在运行的 Storyboard需要停止。我的理解是,在 WPF 中启动新动画将替换任何已运行的现有动画。但是,如果我从两个 DataTrigger 中删除 StopStoryboard,则会遇到另一个问题。这次只有 BidDownStory 会触发。我永远不会看到单元格 Animate Blue。

有时还会发生另一件有趣的事情。如果动画发生在屏幕外(即该列不可见)并且我滚动以使该列可见,我会按预期看到动画。但是,如果我然后将网格滚动回屏幕外的列,动画将继续运行,但针对网格中的不同列!

如果您可以提供任何帮助来解决这些问题,我们将不胜感激。

谢谢

最佳答案

您可以尝试这样的方法:

<DataTrigger Binding="{Binding Path=RowData.Row.BidUp}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource AnimateCellBlue}" />
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource AnimateCellRed}" />
</DataTrigger.ExitActions>
</DataTrigger>

关于wpf - 在 Xaml 中控制 WPF 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10026922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com