NullReference
NullReference

Reputation: 1036

WPF Adorner and ICollectionView Refresh

I have a list box bound to a collection of items. Whenever i call a Refresh on a CollectionView of bound items the adorners disappear from list box items.

Can somebody explain why and how i can overcome this? Should i re-add adorners after each refresh?

Upvotes: 0

Views: 131

Answers (1)

Steven Rands
Steven Rands

Reputation: 5421

An adorner is linked to a particular element, in your case it seems like you are adorning ListBoxItem elements.

When you call the Refresh method on the collection view, this will cause the ListBox control to delete all of its existing ListBoxItem children and recreate them. Your adorners are "disappearing" because the elements they are adorning have been deleted by the list box.

You can either recreate the adorners or try to find some way of refreshing your list box that doesn't involve refreshing the collection view.

Upvotes: 1

Related Questions