实现效果如下:

思路:这里利用了Grid自适应的特点,引入GridLengthAnimation动画效果。
步骤:
1、GridLengthAnimation类
internal class GridLengthAnimation : AnimationTimeline
{
static GridLengthAnimation()
{
FromProperty = DependencyProperty.Register("From", typeof(GridLength), typeof(GridLengthAnimation));
ToProperty = DependencyProperty.Register("To", typeof(GridLength), typeof(GridLengthAnimation));
}
public static readonly DependencyProperty FromProperty;
本文介绍如何在WPF中利用GridLengthAnimation创建手风琴式的照片墙展示效果。通过自定义控件MyGridControl和XAML布局,结合交互逻辑,实现了Grid自适应的动画效果。需要注意在启动动画时正确使用storyboard.Begin(this)避免异常。
订阅专栏 解锁全文
599





