WPFのストーリーボードアニメーションの例外

これは私の完全なコードです

namespace WpfApplication71

{

    /// 
    /// Interaction logic for MainWindow.xaml
    /// 

    public partial class MainWindow : Window
    {
        Frame objframe;
        TransformGroup trGrp;
        TranslateTransform trTns;
        ScaleTransform trScl;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            objframe = new Frame();
            objframe.Background = Brushes.Blue;
            trTns = new TranslateTransform();
            trScl = new ScaleTransform();
            trGrp = new TransformGroup();
            trGrp.Children.Add(trTns);
            trGrp.Children.Add(trScl);
            objframe.RenderTransform = trGrp; 
            objframe.Loaded += new RoutedEventHandler(objframe_Loaded);
            mygrid.Children.Add(objframe);
        }

        void objframe_Loaded(object sender, RoutedEventArgs e)
        {
            var sb1 = new Storyboard();
            var da1 = new DoubleAnimationUsingKeyFrames();
            da1.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)), Value = 0 });
            da1.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(20)), Value = 1, KeySpline = new KeySpline(0, 0, 0.4, 0.969) });
            da1.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(25)), Value = 1, KeySpline = new KeySpline(0, 0, 0.4, 0.969) });
            Storyboard.SetTargetProperty(objframe, new PropertyPath("(UIElement.Opacity)"));
            Storyboard.SetTarget(da1, objframe);
            sb1.Children.Add(da1);
            var da3 = new DoubleAnimationUsingKeyFrames();
            da3.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)), Value = 1 });
            da3.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(15)), Value = 0.8, KeySpline = new KeySpline(0, 0, 0.4, 0.969) });
            da3.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(15)), Value = 1 });
            da3.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(25)), Value = 1 });
            Storyboard.SetTargetProperty(da3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
            Storyboard.SetTarget(da3, objframe);
            sb1.Children.Add(da3);

            var da5 = new DoubleAnimationUsingKeyFrames();
            da5.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)), Value = 1 });
            da5.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(15)), Value = 0.8, KeySpline = new KeySpline(0, 0, 0.4, 0.969) });
            da5.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(15)), Value = 1 });
            da5.KeyFrames.Add(new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(25)), Value = 1 });

            Storyboard.SetTargetProperty(da5, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
            Storyboard.SetTarget(da5, objframe);

            sb1.Children.Add(da5);
            sb1.Begin();
        }
    }
}

ボタンをクリックすると例外が発生する:

Must specify TargetProperty for 'System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames'.

どうすればこの問題を解決できますか?

0
あなたのコードを読んでもらいたい場合は、書式を修正してください(そして、私は欠けている 4-indentation を意味するわけではありませんが、私は新しいラインを意味する)
追加された 著者 H.B.,

1 答え

そのプロパティを設定する必要があります。これは添付プロパティです。 StoryBoard.SetTargetProperty

0
追加された