Storyboard で textBoxの幅を変更

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace wpfsbtest1
{
    /// <summary>
    /// Window1.xaml の相互作用ロジック
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            Play1();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            myStoryboard1.Begin(button1);

        }

        Storyboard myStoryboard1 = new Storyboard();
        DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();

        private void Play1()
        {
            myDoubleAnimation1.From = 100;
            myDoubleAnimation1.To = 300;
            myDoubleAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(3000));

            Storyboard.SetTargetName(myDoubleAnimation1, this.textBox1.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath(TextBox.WidthProperty));

            myStoryboard1.Children.Add(myDoubleAnimation1);
        }
    }
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です