private void SizeForNormalMode(bool animate)
{
ContentControl container = (ContentControl)ItemContainerGenerator.ContainerFromItem(SelectedItem);
if (null != container)
{
// Set height/translation to show just the selected item
if (0 < container.ActualHeight)
{
SetContentHeight(container.ActualHeight + container.Margin.Top + container.Margin.Bottom - (NormalModeOffset * 2));
}
if (null != _itemsPresenterTranslateTransformPart)
{
if (!animate)
{
_itemsPresenterTranslateTransformPart.Y = -NormalModeOffset;
}
_translateAnimation.To = container.Margin.Top - LayoutInformation.GetLayoutSlot(container).Top - NormalModeOffset;
_translateAnimation.From = animate ? null : _translateAnimation.To;
}
}
else
{
// Resize to minimum height
SetContentHeight(0);
}
// Clear highlight of previously selected container
ListPickerItem oldContainer = (ListPickerItem)ItemContainerGenerator.ContainerFromIndex(SelectedIndex);
if (null != oldContainer)
{
oldContainer.IsSelected = false;
}
}