I have UWP app that I use Frame.Navigate() method a lot. By default it seems to be performing transitions with an animation that makes next screen appear sliding from bottom. However, for my case it makes more sense if next screen comes from right or left.
So, to change this default behaviour, I used the following code from this MSDN document:
// Navigate to the right, ie. from LeftPage to RightPage
myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromRight } );
// Navigate to the left, ie. from RightPage to LeftPage
myFrame.Navigate(typeof(LeftPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromLeft } );
but I get this error:
Cannot initialize type 'SlideNavigationTransitionInfo' with a collection initializer because it does not implement 'System.Collections.IEnumerable'
Changing code like this
myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight } );
causes app to crash by Invalid cast exception.
This was an old app that I'm updating so I suspected that might cause the issue and I updated the target version. Now targetting section looks like:
Target version: 1809 (10.0; Build 17763);
Min version : (10.0; 10240)
but still, problem persists. Any idea how to solve this?
If you prefer , You can simply use XAML page transitions, its also compatible with min version 10240: just put below lines in your RightPage or LeftPage XAML source.
<Page.Transitions>
<TransitionCollection>
<EdgeUIThemeTransition Edge="Left">
</EdgeUIThemeTransition>
</TransitionCollection>
</Page.Transitions>