是否可以将一个 Storyboard 资源作为另一个 Storyboard 的子资源包含在内?

发布于 2024-09-30 18:09:43 字数 554 浏览 11 评论 0原文

我知道故事板因其所有的可自由性而很棘手,但是是否可以与多个故事板共享动画?我正在尝试做的事情大致如下:

<UserControl.Resources>
  <Storyboard x:Key="SharedAnimation" />
</UserControl.Resources>

...
  <VisualState Name="Animation1">
    <Storyboard SpeedRatio="1">
      <Somehow include SharedAnimation />
    </Storyboard>
  </VisualState>

  <VisualState Name="Animation2">
    <Storyboard SpeedRatio="1.5">
      <Somehow include SharedAnimation />
    </Storyboard>
  </VisualState>
...    

I know Storyboards are tricky with all of their freezableness, but is it possible to share an animation with multiple Storyboards? Something along the lines of the following is what I'm trying to do:

<UserControl.Resources>
  <Storyboard x:Key="SharedAnimation" />
</UserControl.Resources>

...
  <VisualState Name="Animation1">
    <Storyboard SpeedRatio="1">
      <Somehow include SharedAnimation />
    </Storyboard>
  </VisualState>

  <VisualState Name="Animation2">
    <Storyboard SpeedRatio="1.5">
      <Somehow include SharedAnimation />
    </Storyboard>
  </VisualState>
...    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬シ愛 2024-10-07 18:09:43

我没有在这里尝试,因为我目前这台机器上没有 VS,但这可能有效:

<VisualState Name="Animation1">
  <Storyboard SpeedRatio="1">
    <StaticResource ResourceKey="SharedAnimation" />
  </Storyboard>
</VisualState>

I didn't try it here because I currently don't have VS in this machine, but this might work:

<VisualState Name="Animation1">
  <Storyboard SpeedRatio="1">
    <StaticResource ResourceKey="SharedAnimation" />
  </Storyboard>
</VisualState>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文