简体   繁体   English

WPF Adorner和ICollectionView刷新

[英]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. 每当我在绑定项的CollectionView上调用Refresh时,装饰物就会从列表框项中消失。

Can somebody explain why and how i can overcome this? 有人可以解释为什么以及如何克服吗? Should i re-add adorners after each refresh? 每次刷新后我应该重新添加装饰器吗?

An adorner is linked to a particular element, in your case it seems like you are adorning ListBoxItem elements. 装饰器链接到特定元素,在您的情况下,似乎您正在装饰ListBoxItem元素。

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. 当您在集合视图上调用Refresh方法时,这将导致ListBox控件删除其所有现有ListBoxItem子级并重新创建它们。 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. 您可以重新创建装饰物,也可以尝试找到某种刷新列表框的方法,而无需刷新集合视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM