我尝试在Windows 10 UWP应用中使用ContinuumNavigationTransition效果。我可以在导航页面时让EntranceElement正确地进入,但ExitElement从未动画出来。
作为一个责备案例,我做了一个最低限度的应用程序,仍然没有成功。我的代码如下所示:
MainPage.xaml中
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<ListView x:Name="TheList"
ContinuumNavigationTransitionInfo.ExitElementContainer="True"
ItemsSource="{x:Bind SomeItems}">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
Style="{StaticResource HeaderTextBlockStyle}"
ContinuumNavigationTransitionInfo.IsExitElement="True"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Content="Navigate"
HorizontalAlignment="Center"
Tapped="Button_Tapped"/>
</StackPanel>
</Grid>
MainPage.xaml.cs中
public ObservableCollection<String> SomeItems = new ObservableCollection<string>
{
"Item 1!",
"Item 2!"
};
public MainPage()
{
this.InitializeComponent();
}
private void Button_Tapped(object sender, TappedRoutedEventArgs e)
{
((Frame)Window.Current.Content).Navigate(typeof(SubPage));
}
SubPage.xaml
<Page.Transitions>
<TransitionCollection>
<NavigationThemeTransition>
<NavigationThemeTransition.DefaultNavigationTransitionInfo>
<ContinuumNavigationTransitionInfo/>
</NavigationThemeTransition.DefaultNavigationTransitionInfo>
</NavigationThemeTransition>
</TransitionCollection>
</Page.Transitions>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="I'm an entrance element!"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContinuumNavigationTransitionInfo.IsEntranceElement="True"
TextWrapping="WrapWholeWords"
Style="{StaticResource SubheaderTextBlockStyle}"/>
</Grid>
SubPage.xaml.cs
public SubPage()
{
this.InitializeComponent();
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
SystemNavigationManager.GetForCurrentView().BackRequested += SubPage_BackRequested;
}
private void SubPage_BackRequested(object sender, BackRequestedEventArgs e)
{
((Frame)Window.Current.Content).Navigate(typeof(MainPage));
SystemNavigationManager.GetForCurrentView().BackRequested -= SubPage_BackRequested;
}
答案 0 :(得分:0)
我相信你出错的地方在于你正在使用按钮进行导航,而入口元素和出口元素则用于向上传递上下文。所以理想情况下你应该在listview项目上点击click.Code明智我看不出任何错误并检查这个链接它可能有一些用处。 http://www.visuallylocated.com/post/2014/06/24/Page-transitions-and-animations-in-Windows-Phone-Runtime.aspx