と を使用して、高さが異なるさまざまなコントロールのセットのアニメーションを実装しようとしていCanvas
ますStackpanel
。
したがってStackpanel
、すべての設定を入力して適用しますが、最初はアニメーションがしばらくジャンプし、その後スムーズに進み、終了すると再び2〜3回ジャンプします....
それはなぜですか?古典的なダブルアニメーションなどを使用しています...
手がかりをありがとう!
<Canvas ClipToBounds="True" Name="canMain" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<StackPanel Name="tbmarquee" HorizontalAlignment="Stretch" ></StackPanel>
</Canvas>
private void BottomToTopMarquee()
{
tbmarquee.Orientation = Orientation.Vertical;
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = -tbmarquee.ActualHeight;
doubleAnimation.To = canMain.ActualHeight;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(_marqueeTimeInSeconds));
tbmarquee.BeginAnimation(Canvas.BottomProperty, doubleAnimation);
}
私もこのように試しました
Thread thread = new Thread(new ThreadStart(
delegate()
{
DispatcherOperation dispatcherOp =
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(
delegate()
{
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = -tbmarquee.ActualHeight;
doubleAnimation.To = canMain.ActualHeight;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(_marqueeTimeInSeconds));
tbmarquee.BeginAnimation(Canvas.BottomProperty, doubleAnimation);
}));
dispatcherOp.Completed += new EventHandler(DispatcherOpCompleted);
}));
thread.Start();
つまり、アニメーションがスムーズに開始されず、ジャンプしています..しかし、後で非常にうまくいきます...