Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 26 additions & 34 deletions src/CustomLayouts/Controls/CarouselLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,14 @@ protected override void LayoutChildren (double x, double y, double width, double
_layingOutChildren = false;
}

public static readonly BindableProperty SelectedIndexProperty =
BindableProperty.Create<CarouselLayout, int> (
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);
}
Expand All @@ -88,19 +85,17 @@ void SelectedItemTimerElapsed (object sender, ElapsedEventArgs e) {
SelectedItem = SelectedIndex > -1 ? Children [SelectedIndex].BindingContext : null;
}

public static readonly BindableProperty ItemsSourceProperty =
BindableProperty.Create<CarouselLayout, IList> (
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);
}
Expand Down Expand Up @@ -134,17 +129,14 @@ public DataTemplate ItemTemplate {
set;
}

public static readonly BindableProperty SelectedItemProperty =
BindableProperty.Create<CarouselLayout, object> (
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);
}
Expand Down