roubachof/Sharpnado.CollectionView

Changing ColumnCount after initially set

Closed this issue · 5 comments

After the horror that is Xamarin CollectionView (which you also wrote about), we decided to try Sharpnado.CollectionView.

All seems to be well at first glance, except for one thing: ColumnCount for grid layout.

Our app has a "number of columns" setting. We can set ColumnCount on SHCV in codebehind (it's not bindable) and it works initially. However, applying it again (if our user changes the setting) does nothing. SHCV remains rendered as it initially was. That's a bug, I guess.

Things I have tried as workarounds that failed:

  • nulling and setting ItemsSource again

  • setting ItemWidth to 0

  • shCollectionView.ComputeItemWidth(shCollectionView.Width);

  • shCollectionView.CollectionLayout = Sharpnado.CollectionView.RenderedViews.CollectionViewLayout.Vertical; shCollectionView.CollectionLayout = Sharpnado.CollectionView.RenderedViews.CollectionViewLayout.Grid;
    (this one fails with System.InvalidOperationException: 'ColumnCount should be greater than 0 in order to automatically compute item width' - I'm guessing it defaults to 0 when switching layout to Vertical, which lead me to...)

Something that works:

  • shCollectionView.CollectionLayout = Sharpnado.CollectionView.RenderedViews.CollectionViewLayout.Vertical; shCollectionView.ColumnCount = 1; shCollectionView.CollectionLayout = Sharpnado.CollectionView.RenderedViews.CollectionViewLayout.Grid; shCollectionView.ColumnCount = _applicationManager.LocalAppSettings.NumberOfItemColumns;

That seems to be quite heavy, there's a noticeable delay while SHCV relayouts. It's not a big deal, though, because it's a setting that will rarely, if ever, be changed.

I'm wondering if there's a different (maybe easier?) way of making that work, at least until ColumnCount is made bindable, as per #44 ...

Hey ! Could you try this pre-release and see if it works :)

Sharpnado.CollectionView.2.1.0.zip

Will try later and report back :)

I have another issue that I require assistance with... No changelog for the prerelease, so I don't know if that's also been taken care of, maybe.

does this work for you ?
It needs to go to release :)

Release the Kraken!

will be fixed in 2.1