public void AnimateRearrange(Duration animationDuration, Action rearrangeAction)
{
if (rearrangeAction == null)
{
throw new ArgumentNullException("rearrangeAction");
}
if (this.rearrangeCanvas == null)
{
throw new InvalidOperationException("ReorderListBox control template is missing " +
"a part required for rearrange: " + ReorderListBox.RearrangeCanvasPart);
}
if (this.rearrangeQueue == null)
{
this.rearrangeQueue = new Queue<KeyValuePair<Action, Duration>>();
this.scrollViewer.ScrollToVerticalOffset(this.scrollViewer.VerticalOffset); // Stop scrolling.
this.Dispatcher.BeginInvoke(() =>
this.AnimateRearrangeInternal(rearrangeAction, animationDuration));
}
else
{
this.rearrangeQueue.Enqueue(new KeyValuePair<Action, Duration>(rearrangeAction, animationDuration));
}
}