I have class Model
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");
}
}
}
...
part of XAML code:
<RowDefinition Height="{Binding DetailsPanelHeight}" />
code to do animation (changing row height smoothly):
var animate = new Animation(d => currentItem.DetailsPanelHeight = d, 0, 100);
animate.Commit(this, "ExpandAnimation", 50, 1000, Easing.SpringOut);
code to collapse the row:
var animate = new Animation(d => currentItem.DetailsPanelHeight = d, 100, 0);
animate.Commit(this, "CollapseAnimation", 50, 1000, Easing.SpringOut);
It works for the first time, but for the second time i get an error: "value is less than 0 or is not a number\nParameter name: value". I see d
value is less than zero.
What can i do to fix this problem?
I've used something like this that worked perfectly for me. I hope it fits for you too.
This animation collapses the view cell while calling a command after a delete action invocation. Here's the code:
The tap event handler:
Animation method
Transition callback function
The
InterpolateValue
function as an extension method (very reusable)I hope it works for you.