3

私の WPF アプリケーションには、Blend を使用して作成したウィンドウ ロード アニメーションがあります。実際のアニメーションは正常に動作しますが、(C# を使用して) ウィンドウの読み込みイベントにロジックを追加すると、ウィンドウが最終的にレンダリングされるときにアニメーションがスキップして終了します。

私の最初の計画は、これを解決するために Threading を使用することでしたが、これもうまくいきませんでした:

private void MyWindow_Loaded(object sender, RoutedEventArgs e)
{

    dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
    dispatcherTimer.Interval = new TimeSpan(0, 0, 30);
    dispatcherTimer.Start();

    lstRecipients.Visibility = Visibility.Hidden; 
    windowAdorner = new TransparentAdorner(BorderGrid);

    if (!StaticHelpers.AWSConfigurationExists())
    {
        this.IsEnabled = false;
        GettingStarted gettingStarted = new GettingStarted(this);
        gettingStarted.Owner = this;
        gettingStarted.ShowDialog();
        this.IsEnabled = true;
    }
    else
    {
        Task SetAWSLabelsTask = new Task(new Action(() => SetAWSLabels()));
        SetAWSLabelsTask.Start();

    }

    Task bounceHandler = new Task(new Action(() => processBounce()));
    bounceHandler.Start();
    //processBounce();

    Task unSubscribeHandler = new Task(new Action(() => handleUnsubscriptions()));
    unSubscribeHandler.Start(); 
}

私は、システムがスレッドの作成で非常にビジーであり、その作成が UI スレッドによって処理されているため、ウィンドウがレンダリングされるまでにアニメーションが既に終了していると想定しています。

私が見逃しているのは、アニメーションを調整するための良い方法です。そのため、MyWindow_Loaded にあるビジネス ロジックは、アニメーションの読み込みが完了した後にのみ発生します。

これは可能ですか?

編集:スレッドスリープも試しましたが、これもうまくいきませんでした。

4

1 に答える 1

2

わかりました問題を解決しました。

XAML で、新しいイベント ハンドラーをストーリーボードに追加しました。

<Storyboard x:Key="SESLogoLoad" Completed="StoryCompleted">

次に、C# を使用して手動でメソッドを作成しました。

private void StoryCompleted(object sender, EventArgs e)
{
//Windows onload stuff goes here...
}
于 2013-08-15T23:18:18.140 に答える