private static void OnAutoShiftChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null) { return; } if (e.NewValue == e.OldValue) { return; } EasyCarousel instance = d as EasyCarousel; if (instance == null) { return; } if ((bool)e.NewValue) { instance._timer.Interval = instance.Interval; instance._timer.Start(); } else { instance._timer.Stop(); } }
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null) { return; } if (e.NewValue == e.OldValue) { return; } EasyCarousel instance = d as EasyCarousel; if (instance == null) { return; } var notifyCollection = e.NewValue as INotifyCollectionChanged; if (notifyCollection != null) { notifyCollection.CollectionChanged += (sender, args) => { instance.BindItems(); instance.SelectedItem = (instance.Children[instance.SelectedIndex] as FrameworkElement)?.DataContext; }; } instance.BindItems(); instance.SelectedItem = (instance.Children[instance.SelectedIndex] as FrameworkElement)?.DataContext; }
private static void OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null) { return; } if (e.NewValue == e.OldValue) { return; } EasyCarousel instance = d as EasyCarousel; if (instance == null) { return; } if (DesignMode.DesignModeEnabled) { return; } instance.ShiftElementsAnimatedly((int)e.NewValue); instance.SelectedItem = (instance.Children[(int)e.NewValue] as FrameworkElement)?.DataContext; }
private static void OnIntervalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null) { return; } if (e.NewValue == e.OldValue) { return; } EasyCarousel instance = d as EasyCarousel; if (instance == null) { return; } instance._timer.Interval = (TimeSpan)e.NewValue; }
private static void OnItemSpacingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null) { return; } if (e.NewValue == e.OldValue) { return; } EasyCarousel instance = d as EasyCarousel; if (instance == null) { return; } instance.InvalidateArrange(); }