0
ボタンとコントロールがあり、スタックパネルもあるメインフレームがあります。 ))私は、次のクールな機能を書いてきた.csファイルにXAMLから働いていたアニメーションを移動しようとすると:厚さアニメーショントラブル? (Begin function parameters)
private void ToggleButton_Checked(object sender, RoutedEventArgs e)
{
int heightBottom = 100;
System.Windows.Thickness th = stackPanel1.Margin;
th.Top = stackPanel1.Margin.Top + heightBottom;
ThicknessAnimation animStackPanel1 = new ThicknessAnimation
{
From = stackPanel1.Margin,
To = th,
AccelerationRatio = 0.2,
FillBehavior = FillBehavior.Stop,
DecelerationRatio = 0.8,
Duration = DURATION
};
System.Windows.Thickness th2 = fxPSEditorView.Margin;
th2.Right = fxPSEditorView.Margin.Right - heightBottom;
th2.Bottom = fxPSEditorView.Margin.Bottom - heightBottom;
ThicknessAnimation animPSEditorView = new ThicknessAnimation
{
From = fxPSEditorView.Margin,
To = th2,
AccelerationRatio = 0.2,
FillBehavior = FillBehavior.Stop,
DecelerationRatio = 0.8,
Duration = DURATION
};
Storyboard.SetTarget(animPSEditorView, fxPSEditorView);
Storyboard.SetTargetProperty(fxPSEditorView, new PropertyPath(MarginProperty));
sb.Children.Add(animPSEditorView);
Storyboard.SetTarget(animStackPanel1, stackPanel1);
Storyboard.SetTargetProperty(stackPanel1, new PropertyPath(MarginProperty));
sb.Children.Add(animStackPanel1);
sb.Begin();//null reference error here!
};
私はsb.Beginのための2つのパラメータを指定する必要があります理解したよう - stackPanel1用とその他はfxPSEditorViewためです。しかし、最初のパラメータとしてオブジェクトのセットを取ることはありません。 このアニメーションをどのように実行するかについてのアイデアはうまくいきます!
自分自身でエラーが見つかりました:これは正しくありませんStoryboard.SetTargetProperty(fxPSEditorView、new PropertyPath(MarginProperty));これは正しいStoryboard.SetTargetProperty(animPSEditorView、新しいPropertyPath(MarginProperty)); –