【发布时间】:2018-01-15 09:47:18
【问题描述】:
我想要一个 AnimationClock 来更改 datagridcell 的字体粗细。
我已经在颜色上做了,效果很好,见下面的代码。
ColorAnimation ca = new ColorAnimation(Colors.Black, Colors.Yellow, new Duration(TimeSpan.FromSeconds(3)));
ca.AutoReverse = true;
dataGridCell.Foreground = new SolidColorBrush(Colors.Black);
dataGridCell.Foreground.BeginAnimation(SolidColorBrush.ColorProperty, ca);
但是对于 fontWeight 他们没有提供 dataGridCell.FontWeight.BeginAnimation 方法。
所以我必须做一个 ApplyAnimationClock。 我就是这样做的,但是失败了。
DoubleAnimation da = new DoubleAnimation(400.0, 600.0, new
Duration(TimeSpan.FromSeconds(3)));
da.AutoReverse = true;
AnimationClock ac = da.CreateClock();
dataGridCell.FontWeight = FontWeight.FromOpenTypeWeight(400);
dataGridCell.ApplyAnimationClock(DataGridCell.FontWeightProperty, ac);
我想将字体粗细从 400 更改为 600。但它在下面给了我这个例外。
附加信息:“System.Windows.Media.Animation.DoubleAnimation”类型的 AnimationTimeline 不能用于为“System.Windows.FontWeight”类型的“FontWeight”属性设置动画。
我的问题很简单,我想改变 datagridcell 的字体粗细,然后在 3 秒后恢复正常。如果有一个简单的方法可以做到这一点,请告诉我。
【问题讨论】:
标签: c# wpf datagrid datagridcell