我有一個WPF應用程序,當數據源中的值已更新並且工作正常時,它會執行單元格閃爍。如何正確停止以編程方式聲明的故事板
我注意到,當我執行更新的應用程序分析真的很快,內存越來越大。由於我以這種方式啓動故事板
private static DoubleAnimation blink =
new DoubleAnimation()
{
From = 0,
To = 1,
Duration = TimeSpan.FromSeconds(0.2),
FillBehavior = FillBehavior.Stop
};
private void Items_ItemChanged(object sender, ItemChangedEventArgs<ExpandoObject> e)
{
var club = e.Item;
var row = grid.ItemContainerGenerator.ContainerFromItem(club) as Telerik.Windows.Controls.GridView.GridViewRow;
if (row != null)
{
var column = grid.Columns[e.PropertyName];
var cell = row.Cells.FirstOrDefault(c => c.Column == column);
if (cell != null) //In case of virtualization I won't have all the columns
{
Storyboard.SetTarget(blink, cell.Content as TextBlock);
Storyboard.SetTargetProperty(blink, new PropertyPath(Button.OpacityProperty));
var sb = new Storyboard();
sb.Children.Add(blink);
sb.Begin();
}
}
}
我懷疑我必須停止動畫,但我不知道我該怎麼做呢?
感謝
謝謝,這種方式我可以阻止它,或者它很好嗎? – advapi
@advapi檢查並告訴 – AnjumSKhan
你很棒,沒有更多的記憶成長! – advapi