【问题标题】:Silverlight width smooth animationSilverlight 宽度平滑动画
【发布时间】:2010-11-23 22:12:15
【问题描述】:

我有带有文本块内容的容器。文本块文本将更改为任何文本。我需要用动画改变容器的大小。最好的方法是什么?

例子

来自: [你好世界文字] 至: [你好]

带有动画。

【问题讨论】:

    标签: .net silverlight animation


    【解决方案1】:

    当您更新 TextBlock 的文本时,您应该通过代码为容器的宽度设置动画:

    // right before updating the text:
    textBlock.Text = "hello";
    textBlock.UpdateLayout();
    // animation is a DoubleAnimation
    animation.From = container.ActualWidth;
    animation.To = textBlock.ActualWidth;
    // storyBoard is a Storyboard that contains animation and targets container.Width
    storyBoard.Begin();
    

    我担心你不能只使用 XAML 来做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 2023-03-16
      • 2012-09-17
      • 1970-01-01
      • 2017-09-19
      相关资源
      最近更新 更多