private double GetItemHeight(ViewModelBase viewModel)
        {
            var ai = new AgendaItemControl();

            ai.Width       = ItemsHost.ActualWidth;
            ai.DataContext = viewModel;
            ai.Measure(new Size(int.MaxValue, int.MaxValue));
            return(ai.DesiredSize.Height);
        }
        private void LoadItems(List <ViewModelBase> items)
        {
            StopAnimation();
            // #1 Hide old items
            if (ItemsHost.Children.Count > 0)
            {
                _oldItems = ItemsHost.Children.ToList();
                for (int i = 0; i < ItemsHost.Children.Count; i++)
                {
                    var oldItem = ItemsHost.Children[i] as FrameworkElement;
                    _transitionStoryboard.Children.Add(RotateItem(oldItem, i * (_duration / 2), 0, 90, EasingMode.EaseIn));
                }
            }

            double topOffset = 0;

            // #2 Show new items
            for (int i = 0; i < items.Count; i++)
            {
                var ai = new AgendaItemControl();
                ai.DataContext = items[i];
                ai.Width       = ItemsHost.ActualWidth;
                ai.Projection  = new PlaneProjection()
                {
                    RotationX = -90
                };
                Canvas.SetTop(ai, topOffset);
                double height = GetItemHeight(items[i]);

                // Item is too big, cut it off.
                if (height > LayoutRoot.ActualHeight)
                {
                    ai.Height = LayoutRoot.ActualHeight;
                }

                ItemsHost.Children.Add(ai);

                // Calculate next item offset.
                _transitionStoryboard.Children.Add(RotateItem(ai, (i + 1) * (_duration / 2), -90, 0, EasingMode.EaseIn));
                topOffset += height;
            }

            _transitionStoryboard.Begin();
        }