views:

41

answers:

1

I have a DataTemplate that I use to display details from a class in a ListBox. The DataTemplate has an EventTrigger attached to the (item) Loaded event that uses a DoubleAnimation to fade each item into view as they are added to the ObservableCollection that is bound to the ListBox. It also has a DataTrigger that uses a DoubleAnimation and a ColorAnimation (RepeatBehavior="Forever") to animate a glow effect under a certain condition. So far, so good.

The application requires that the item properties need to be updated every few seconds. The problem comes after updating a property of an item in the ListBox, when calling ListBox.Items.Refresh(). This resets the animations, so that each item fades into view and the glow effect restarts every few seconds. The item property values don't update if I don't call Refresh. My question is, is there a way to refresh each item individually or get around this problem somehow?

+1  A: 

Make sure the individual items in your ObservableCollection<T> implement INotifyPropertyChanged. As long as they do, the bindings should update automatically, without requiring an explicit refresh.

Reed Copsey
Ah sorry Reed, I just answered myself before I saw your answer. I'll give you credit anyway. :)
Sheridan