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.Core | |
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.Core')
-rw-r--r-- | Xamarin.Forms.Core/CarouselView.cs | 17 | ||||
-rw-r--r-- | Xamarin.Forms.Core/IItemViewController.cs | 1 | ||||
-rw-r--r-- | Xamarin.Forms.Core/ItemsViewSimple.cs | 19 |
3 files changed, 11 insertions, 26 deletions
diff --git a/Xamarin.Forms.Core/CarouselView.cs b/Xamarin.Forms.Core/CarouselView.cs index b0be847f..68c387b6 100644 --- a/Xamarin.Forms.Core/CarouselView.cs +++ b/Xamarin.Forms.Core/CarouselView.cs @@ -24,10 +24,8 @@ namespace Xamarin.Forms defaultBindingMode: BindingMode.TwoWay ); - #region Fields object _lastItem; int _lastPosition; - #endregion public CarouselView() { @@ -37,14 +35,12 @@ namespace Xamarin.Forms HorizontalOptions = LayoutOptions.FillAndExpand; } - #region Private Members object GetItem(int position) { var controller = (IItemViewController)this; object item = controller.GetItem(position); return item; } - #endregion // non-public bc unable to implement on iOS internal event EventHandler<ItemVisibilityEventArgs> ItemAppearing; @@ -55,9 +51,10 @@ namespace Xamarin.Forms get { return (int)GetValue(PositionProperty); } set { SetValue(PositionProperty, value); } } - public int Item + public object Item { - get { return (int)GetValue(ItemProperty); } + get { return GetValue(ItemProperty); } + internal set { SetValue(ItemProperty, value); } } public event EventHandler<SelectedItemChangedEventArgs> ItemSelected; @@ -81,16 +78,18 @@ namespace Xamarin.Forms { if (item.Equals(_lastItem)) return; - - ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs(item)); _lastItem = item; + + Item = item; + ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs(item)); } void ICarouselViewController.SendSelectedPositionChanged(int position) { if (_lastPosition == position) return; - _lastPosition = position; + + Item = ((IItemViewController)this).GetItem(position); PositionSelected?.Invoke(this, new SelectedPositionChangedEventArgs(position)); } } diff --git a/Xamarin.Forms.Core/IItemViewController.cs b/Xamarin.Forms.Core/IItemViewController.cs index 79f711e9..0876f602 100644 --- a/Xamarin.Forms.Core/IItemViewController.cs +++ b/Xamarin.Forms.Core/IItemViewController.cs @@ -6,5 +6,6 @@ View CreateView(object itemType); object GetItem(int index); object GetItemType(object item); + int Count { get; } } }
\ No newline at end of file diff --git a/Xamarin.Forms.Core/ItemsViewSimple.cs b/Xamarin.Forms.Core/ItemsViewSimple.cs index 51b9df7a..59858d22 100644 --- a/Xamarin.Forms.Core/ItemsViewSimple.cs +++ b/Xamarin.Forms.Core/ItemsViewSimple.cs @@ -30,8 +30,6 @@ namespace Xamarin.Forms { } - public int Count => _itemSource.Count; - public IEnumerable ItemsSource { get { return (IEnumerable)GetValue(ItemsSourceProperty); } @@ -44,6 +42,8 @@ namespace Xamarin.Forms set { SetValue(ItemTemplateProperty, value); } } + int IItemViewController.Count => _itemSource.Count; + void IItemViewController.BindView(View view, object item) { view.BindingContext = item; @@ -192,21 +192,6 @@ namespace Xamarin.Forms return new Enumerator(this); } - public int IndexOf(object item) - { - // madness ported from listProxy - CollectionSynchronizationContext syncContext = SyncContext; - if (syncContext != null) - { - int value = -1; - syncContext.Callback(Enumerable, SyncContext.Context, () => value = _indexable.IndexOf(item), false); - - return value; - } - - return _indexable.IndexOf(item); - } - void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Action onCollectionChanged = () => |