等同于NSCollectionView的ReloadData重绘项目视图 [英] Equivalent of ReloadData for NSCollectionView to redraw item views
问题描述
我有一个切换来改变字体属性。在我的NSOutlineView中,我调用ReloadData来重新渲染所有内容。但是,如何强制NSCollectionView重新渲染。我尝试了
I have a toggle to change the font attributes. In my NSOutlineView, I call ReloadData to have everything re-render. However, how can I force NSCollectionView to re-render. I tried
cvReader.NeedsLayout= true;
cvReader.Layout();
cvReader.NeedsDisplay = true;
cvReader.Display();
无效。任何提示非常感谢。
to no avail. Any hints much appreciated.
更新。我也尝试过
cvReader.NeedsDisplay = true;
cvReader.Window.ViewsNeedDisplay = true;
cvReader.Window.FlushWindowIfNeeded();
以及再次分配内容。它感觉就像项目视图被缓存和不重新生成。也许有一种方法可以清除项目视图缓存?
As well as assigning the content again. It feels like the item views are cached and not regenerated. Maybe there is a way to clear the item view cache?
推荐答案
结果是NSCollectionView项目视图可以通过设置ItemPrototype,例如
Turns out that the NSCollectionView item views can be refreshed by setting the ItemPrototype, e.g.,
ItemPrototype = new SomeViewController()
这会导致重新创建所有现有的视图。
This causes all the existing views to be recreated.
这篇关于等同于NSCollectionView的ReloadData重绘项目视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!