0

我不明白为什么双动画事件会触发两次。富文本框在完成的方法上得到更新。当它淡出时,我从队列中更改文本。然后动画再次开始。当队列为空时,它会补充新数据。但是因为事件触发了两次,所以它会跳过一些文本。

Private Sub CreateNewsAnimation()
    fadingNewsAnimation.From = 0
    fadingNewsAnimation.To = 1
    fadingNewsAnimation.AutoReverse = True
    fadingNewsAnimation.Duration = New Duration(TimeSpan.FromSeconds(newsDuration))
    AddHandler fadingNewsAnimation.Completed, AddressOf fadingNewsAnimation_Completed
    RTBoxNewsBottom.BeginAnimation(UIElement.OpacityProperty, fadingNewsAnimation)
End Sub

Private Sub fadingNewsAnimation_Completed(ByVal sender As Object, ByVal e As EventArgs)
    If enableEvent = True Then
        If m_NewsQueue.Count > 0 Then
            Using newsMemStream As New IO.MemoryStream(System.Text.ASCIIEncoding.[Default].GetBytes(m_NewsQueue.Dequeue()))
                RTBoxNewsBottom.Selection.Load(newsMemStream, DataFormats.Rtf)
                RTBoxNewsBottom.BeginAnimation(UIElement.OpacityProperty, fadingNewsAnimation)
            End Using
        Else
            PopulateNewsQueue()
        End If
    End If
End Sub
4

0 回答 0