-->

Equivalent of ReloadData for NSCollectionView to r

2019-08-02 17:58发布

问题:

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.

Update. I also tried

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?

回答1:

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.