私は2つのアニメーションを持っています:
<Storyboard x:Key="ChangeLayout">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="currentContent">
<EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="900"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="HideLayout">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="currentContent">
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="-900">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
そして、それらを開始するコード:
private void btnUser_Click(object sender, RoutedEventArgs e)
{
if (currentContent.Content != null)
if (currentContent.Content.GetType() == typeof(Layouts.User))
return;
((hl.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as EasingDoubleKeyFrame).Value = -this.ActualWidth;
hl.Completed += (_sender, _e) =>
{
currentContent.Content = new Layouts.User();
cl.Completed += (ssender, ee) =>
{
btnMusic.Opacity = 0.5;
btnUser.Opacity = 0.9;
};
cl.Begin();
};
hl.Begin();
}
private void btnMusic_Click(object sender, RoutedEventArgs e)
{
if (currentContent.Content != null)
if (currentContent.Content.GetType() == typeof(Layouts.Music))
return;
((hl.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as EasingDoubleKeyFrame).Value = -this.ActualWidth;
hl.Completed += (_sender, _e) =>
{
if (Layouts.Music.CurrentMusic == null)
{
Layouts.Music.CurrentMusic = new Layouts.Music();
Layouts.Music.CurrentMusic.GetMusic();
}
currentContent.Content = Layouts.Music.CurrentMusic;
cl.Completed += (ssender, ee) =>
{
btnUser.Opacity = 0.5;
btnMusic.Opacity = 0.8;
};
cl.Begin();
};
hl.Begin();
}
ユーザーと音楽のコンテンツを数回切り替えた後、500 + から最大 4eh にドロップを切り替えた後、WPF Performance Suite FPS アニメーションに従って、ChangeLayout アニメーションが非常に遅くラグが発生し、アニメーション化されます ... これに対する解決策が見つかりません=(
私の英語はごめんなさい、私は今のところ勉強しています。