diff --git a/src/CustomLayouts/Controls/CarouselLayout.cs b/src/CustomLayouts/Controls/CarouselLayout.cs index 58cc324..ceef50b 100644 --- a/src/CustomLayouts/Controls/CarouselLayout.cs +++ b/src/CustomLayouts/Controls/CarouselLayout.cs @@ -59,17 +59,14 @@ protected override void LayoutChildren (double x, double y, double width, double _layingOutChildren = false; } - public static readonly BindableProperty SelectedIndexProperty = - BindableProperty.Create ( - carousel => carousel.SelectedIndex, - 0, - BindingMode.TwoWay, - propertyChanged: (bindable, oldValue, newValue) => { - ((CarouselLayout)bindable).UpdateSelectedItem (); - } - ); - - public int SelectedIndex { + public static readonly BindableProperty SelectedIndexProperty = + BindableProperty.Create("SelectedIndex", typeof(int), typeof(CarouselLayout), 0, BindingMode.TwoWay, + propertyChanged: (bindable, oldValue, newValue) => { + ((CarouselLayout)bindable).UpdateSelectedItem(); + } + ); + + public int SelectedIndex { get { return (int)GetValue (SelectedIndexProperty); } @@ -88,19 +85,17 @@ void SelectedItemTimerElapsed (object sender, ElapsedEventArgs e) { SelectedItem = SelectedIndex > -1 ? Children [SelectedIndex].BindingContext : null; } - public static readonly BindableProperty ItemsSourceProperty = - BindableProperty.Create ( - view => view.ItemsSource, - null, - propertyChanging: (bindableObject, oldValue, newValue) => { - ((CarouselLayout)bindableObject).ItemsSourceChanging (); - }, - propertyChanged: (bindableObject, oldValue, newValue) => { - ((CarouselLayout)bindableObject).ItemsSourceChanged (); - } - ); - - public IList ItemsSource { + public static readonly BindableProperty ItemsSourceProperty = + BindableProperty.Create("ItemsSource", typeof(IList), typeof(CarouselLayout), null, + propertyChanging: (bindableObject, oldValue, newValue) => { + ((CarouselLayout)bindableObject).ItemsSourceChanging(); + }, + propertyChanged: (bindableObject, oldValue, newValue) => { + ((CarouselLayout)bindableObject).ItemsSourceChanged(); + } + ); + + public IList ItemsSource { get { return (IList)GetValue (ItemsSourceProperty); } @@ -134,17 +129,14 @@ public DataTemplate ItemTemplate { set; } - public static readonly BindableProperty SelectedItemProperty = - BindableProperty.Create ( - view => view.SelectedItem, - null, - BindingMode.TwoWay, - propertyChanged: (bindable, oldValue, newValue) => { - ((CarouselLayout)bindable).UpdateSelectedIndex (); - } - ); + public static readonly BindableProperty SelectedItemProperty = + BindableProperty.Create("SelectedItem", typeof(object), typeof(CarouselLayout), null, BindingMode.TwoWay, + propertyChanged: (bindable, oldValue, newValue) => { + ((CarouselLayout)bindable).UpdateSelectedIndex(); + } + ); - public object SelectedItem { + public object SelectedItem { get { return GetValue (SelectedItemProperty); }