I tried using Toolkit for page transitions, but all animations stuttered. In another question, I was asked not to use the toolkit, so I myself implemented all the animations and manually started them. For example, going to another page:
void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = sender as ListBox;
if (null == listBox) return;
Data.Category item = listBox.SelectedItem as Data.Category;
if (null == item) return;
Uri uri = new Uri(App.MakeResourcePathTo(item.Page), UriKind.Relative);
Storyboard storyboard = Application.Current.Resources["FlipForwardOut"] as Storyboard;
Storyboard.SetTarget(storyboard, LayoutRoot);
EventHandler completedHandler = delegate { };
completedHandler = delegate
{
NavigationService.Navigate(uri);
storyboard.Stop();
storyboard.Completed -= completedHandler;
};
storyboard.Completed += completedHandler;
storyboard.Begin();
listBox.SelectedIndex = -1;
}
Is the code good? There, as I understand it, there will be nothing else that runs parallel to this code. This is exactly what I wanted, because then nothing would hinder my animation and slow it down.
Here is another piece of code. This shows how I handle inverse animation.
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
Storyboard storyboard = Application.Current.Resources["FlipBackwardOut"] as Storyboard;
Storyboard.SetTarget(storyboard, LayoutRoot);
EventHandler completedHandler = delegate { };
completedHandler = delegate
{
storyboard.Stop();
storyboard.Completed -= completedHandler;
NavigationService.GoBack();
};
storyboard.Completed += completedHandler;
storyboard.Begin();
}
Is there something wrong with this code that might cause performance issues?
Animations are very simple, only linear animations:
<Storyboard x:Key="FlipForwardOut">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
<LinearDoubleKeyFrame KeyTime="0" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="70"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
<LinearDoubleKeyFrame KeyTime="0" Value="1"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="0.1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
, : , . , . , , ( ).
- , , , ?
: , (LayoutRoot Y = 70, opacity = 0), ( LayoutRoot Y = 0 opacity = 1), .
?
, - .
, . , , , .
. .: (