【发布时间】:2010-11-23 22:12:15
【问题描述】:
我有带有文本块内容的容器。文本块文本将更改为任何文本。我需要用动画改变容器的大小。最好的方法是什么?
例子
来自: [你好世界文字] 至: [你好]
带有动画。
【问题讨论】:
标签: .net silverlight animation
我有带有文本块内容的容器。文本块文本将更改为任何文本。我需要用动画改变容器的大小。最好的方法是什么?
例子
来自: [你好世界文字] 至: [你好]
带有动画。
【问题讨论】:
标签: .net silverlight animation
当您更新 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 来做到这一点。
【讨论】: