EntranceThemeAnimation只是第一次出场 [英] EntranceThemeAnimation played only the first time
问题描述
我在C#和Xaml开发Metro风格应用程序,其框架和页面用于导航。
Im'developing a Metro Style App in C# and Xaml with a Frame and pages for navigation.
In我的一个页面我有三个不同内容的网格; 我以这种方式向每个网格应用了一个EntranceThemeAnimation:
In one of my page I have three grids with different content; I applied to each grid an EntranceThemeAnimation in this way:
< Grid.Transitions>
< TransitionCollection>
< EntranceThemeTransition />
< / TransitionCollection>
< /Grid.Transitions>
<Grid.Transitions>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</Grid.Transitions>
我的网格在页面启动时全部折叠,然后,根据用户的选择,我一次显示一个网格,通过视觉状态改变可见性。
但是,只有在第一次显示每个网格时才会播放EntranceAnimation。当我第二次改变视觉状态显示网格时,动画不再播放。
My grids are all collapsed at page startup and then, depending on user choice, I show a grid at a time changing visibility through visual states.
But the EntranceAnimation is played only the first time each grid is shown. When I show a grid the second time changing visual state, the animation is no more played.
每当我通过视觉显示改变其可见性的网格时,是否可以播放EntranceAnimation州?
Is it possibile to play an EntranceAnimation each time I show the gird changing its visibility through visual state?
推荐答案
我测试了这个似乎是入口主题将在控制树中添加一次。 我发现如果我从其父控件的children属性中删除有问题的网格,那么当我将其添加回来时,它将再次播放入口
主题。
I tested this and it seems that the entrance theme will play once upon addition to the control tree. I found that if I remove the grid in question from the children property of its parent control, then when I add it back, it will play the entrance theme again.
Grid theGrid;
public BlankPage()
{
this.InitializeComponent();
theGrid = MyGrid; // theGrid hold the Grid which has the transistion
MyStackPanel.Children.Remove(MyGrid); // Remove it from the control tree upon start
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MyStackPanel.Children.Insert(0, theGrid); // Add it before display
theGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
MyGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
MyStackPanel.Children.Remove(theGrid); // Remove it upon collapse
}
这篇关于EntranceThemeAnimation只是第一次出场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!