我有班级模型
public class Model : INotifyPropertyChanged
...
private GridLength detailsPanelHeight { get; set; }
public GridLength DetailsPanelHeight
{
get { return detailsPanelHeight; }
set
{
if (!GridLength.Equals(detailsPanelHeight, value))
{
detailsPanelHeight = value;
OnPropertyChanged("DetailsPanelHeight");
}
}
}
...
XAML 代码的一部分:
<RowDefinition Height="{Binding DetailsPanelHeight}" />
做动画的代码(平滑地改变行高):
var animate = new Animation(d => currentItem.DetailsPanelHeight = d, 0, 100);
animate.Commit(this, "ExpandAnimation", 50, 1000, Easing.SpringOut);
折叠行的代码:
var animate = new Animation(d => currentItem.DetailsPanelHeight = d, 100, 0);
animate.Commit(this, "CollapseAnimation", 50, 1000, Easing.SpringOut);
它第一次工作,但第二次出现错误:“值小于 0 或不是数字\n参数名称:值”。我看到d
价值小于零。
我能做些什么来解决这个问题?