//打开分组视图
void citiesListGropus_GroupViewOpened(object sender, GroupViewOpenedEventArgs e)
{
ItemContainerGenerator itemContainerGenerator = e.ItemsControl.ItemContainerGenerator;
TurnstileTransition turnstileTransition = new TurnstileTransition();
turnstileTransition.Mode = TurnstileTransitionMode.ForwardIn;
int itemCount = e.ItemsControl.Items.Count;
for (int i = 0; i < itemCount; i++)
{
UIElement element = itemContainerGenerator.ContainerFromIndex(i) as UIElement;
ITransition animation = turnstileTransition.GetTransition(element);
animation.Begin();
}
}
//关闭分组视图
void citiesListGropus_GroupViewClosing(object sender, GroupViewClosingEventArgs e)
{
e.Handled = true;
SwivelTransition transition = new SwivelTransition();
ItemContainerGenerator itemContainerGenerator = e.ItemsControl.ItemContainerGenerator;
int animationFinished = 0;
int itemCount = e.ItemsControl.Items.Count;
for (int i = 0; i < itemCount; i++)
{
UIElement element = itemContainerGenerator.ContainerFromIndex(i) as UIElement;
ITransition animation = transition.GetTransition(element);
animation.Completed += delegate
{
if ((++animationFinished) == itemCount)
{
citiesListGropus.CloseGroupView();
citiesListGropus.ScrollToGroup(e.SelectedGroup);
}
};
animation.Begin();
}
}