diff options
author | kingces95 <kingces95@users.noreply.github.com> | 2016-04-18 11:39:23 -0700 |
---|---|---|
committer | Samantha Houts <samantha@teamredwall.com> | 2016-04-18 11:39:23 -0700 |
commit | 0d57b35f21b9499876c65c7be6d11637543605aa (patch) | |
tree | 93ac3a3b3dd699d11f6a5dd7a3864bc32b8eee8e /Xamarin.Forms.Platform.iOS/Renderers | |
parent | 8f5c5e4e06b1ec5b781a6c20d75a67c8d82234f2 (diff) | |
download | xamarin-forms-0d57b35f21b9499876c65c7be6d11637543605aa.tar.gz xamarin-forms-0d57b35f21b9499876c65c7be6d11637543605aa.tar.bz2 xamarin-forms-0d57b35f21b9499876c65c7be6d11637543605aa.zip |
CarouselView Fixes (#101)
* Fix CarouselView.Item
* CarouselView formatting
* Move ItemsView.Count to IItemsViewController
* Remove dead code: CarouselView.IndexOf
* CarouselView re-layout subviews on resize.
* Add ItemTemplate to resources.xaml on UWP
* Docs
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Renderers')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs index 3efb316b..5bc2b8de 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs @@ -55,16 +55,9 @@ namespace Xamarin.Forms.Platform.iOS int _position; CarouselViewController _controller; + RectangleF _lastBounds; #endregion - new UIScrollView Control - { - get - { - Initialize(); - return base.Control; - } - } ICarouselViewController Controller { get { return Element; } @@ -76,6 +69,7 @@ namespace Xamarin.Forms.Platform.iOS if (carouselView != null) return; + _lastBounds = Bounds; _controller = new CarouselViewController( renderer: this, initialPosition: Element.Position @@ -141,7 +135,7 @@ namespace Xamarin.Forms.Platform.iOS break; case NotifyCollectionChangedAction.Remove: - if (Element.Count == 0) + if (Controller.Count == 0) throw new InvalidOperationException("CarouselView must retain a least one item."); if (e.OldStartingIndex == _position) @@ -149,7 +143,7 @@ namespace Xamarin.Forms.Platform.iOS _controller.DeleteItems( Enumerable.Range(e.OldStartingIndex, e.OldItems.Count) ); - if (_position == Element.Count) + if (_position == Controller.Count) _position--; OnItemChange(_position); } @@ -220,6 +214,17 @@ namespace Xamarin.Forms.Platform.iOS } } + public override void LayoutSubviews() + { + base.LayoutSubviews(); + + if (_lastBounds == Bounds) + return; + + base.Control.ReloadData(); + _lastBounds = Bounds; + _controller.ScrollToPosition(_position, false); + } public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { return Control.GetSizeRequest(widthConstraint, heightConstraint, DefaultMinimumDimension, DefaultMinimumDimension); @@ -352,7 +357,7 @@ namespace Xamarin.Forms.Platform.iOS } public override nint GetItemsCount(UICollectionView collectionView, nint section) { - var result = Element.Count; + var result = Controller.Count; return result; } public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) |