0
下のコードから画像ボタンにアニメーションを提供することができます。Wpfのアニメーションを無効にする
this.RegisterName(image1.Name, image1);
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 1.0;
myDoubleAnimation.To = 0.0;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.25));
myDoubleAnimation.AutoReverse = true;
myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
myStoryboard = new Storyboard();
myStoryboard.Children.Add(myDoubleAnimation);
Storyboard.SetTargetName(myDoubleAnimation, image1.Name);
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Image.OpacityProperty));
myStoryboard.Begin(this);
アニメーションを停止する必要があります。
以下はサンプルコードです。
TimeSpan? ts = new TimeSpan(0,0,2);
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 1.0;
myDoubleAnimation.To = 0.0;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));
myStoryboard.BeginTime = ts;
myDoubleAnimation.AutoReverse = true;
myStoryboard = new Storyboard();
myStoryboard.Children.Remove(myDoubleAnimation);
myStoryboard.Stop(this);
イメージボタンのアニメーションを停止できません。 上記の問題について私に案内してください。
よろしく、あなたが開始されなかったStoryboard
を停止しているかのように見えます
サチンK
こんにちはケント、 私はXaml(Wpf)技術には初めてです。 私はmystoryboardの初期化を削除しました。上記の2つはボタンイベントで発生しています。私は両方のイベントの前にmystoryboardを初期化しました。私は共通の参照を維持しようとしました。しかしそれでもそれは止まらない。 –
ケントに感謝、私は解決策を得ました。私はこれを使用しました。 myStoryboard.Begin(this、true); –