私は私を殺している問題があります。以下は高さの設定をアニメーションした後に、このプロパティが直接動作を停止します
private void _resizeButton_Click(object sender, RoutedEventArgs e)
{
button.Height += 10;
}
private void _animateButton_Click(object sender, RoutedEventArgs e)
{
Storyboard storyboard = new Storyboard();
DoubleAnimation animation = new DoubleAnimation(button.Height + 10, new Duration(new TimeSpan(0, 0, 0, 1)));
storyboard.Children.Add(animation);
Storyboard.SetTargetName(animation, button.Name);
Storyboard.SetTargetProperty(animation, new PropertyPath(HeightProperty));
storyboard.Begin(_grid);
}
アプリケーションが_resizeButtonはボタンがすぐに大きく左に押した後、この
のように見えるの後ろ
<Grid Name="_grid">
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="36,33,0,0" Name="button" VerticalAlignment="Top" Width="75" />
<Button Content="Enlarge through animation" Height="23" Margin="172,33,24,0" Name="_animateButton" VerticalAlignment="Top" Click="_animateButton_Click" />
<Button Content="Enlarge through simple heigh changing" Height="23" Margin="172,62,24,0" Name="_resizeButton" VerticalAlignment="Top" Click="_resizeButton_Click" />
</Grid>
とコードで簡単な例です。次に、_animateButtonを押しています - 左ボタンがゆっくりと拡大しています。その後、私は_resizeButtonをもう一度押して、何も起こっていません。何故ですか?
私は同じことがTopプロパティ
あなたの答えはありがたいですが、animation.FillBehavior = FillBehaviorを設定していただきありがとうございます。縮小率を最後の高さの値に戻してください。私は何か間違っているのですか? – bizon
ありがとうございました!!!時間を節約しました! – Rocklan