コード例 #1
0
        private void _carouselView_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(_carouselView.SelectedIndex) && !_supressCarouselViewPositionChangedEvent)
            {
                var positionChangingArgs = new PositionChangingEventArgs()
                {
                    Canceled    = false,
                    NewPosition = _carouselView.SelectedIndex,
                    OldPosition = _position
                };

                OnPositionChanging(ref positionChangingArgs);

                if (positionChangingArgs != null && positionChangingArgs.Canceled)
                {
                    _supressCarouselViewPositionChangedEvent = true;
                    _carouselView.ItemAppearing             -= _carouselView_PositionSelected;
                    _carouselView.PropertyChanged           -= _carouselView_PropertyChanged;
                    _carouselView.SelectedIndex              = _position;
                    _carouselView.ItemAppearing             += _carouselView_PositionSelected;
                    _carouselView.PropertyChanged           += _carouselView_PropertyChanged;
                    _supressCarouselViewPositionChangedEvent = false;
                }
            }
        }
コード例 #2
0
        protected virtual void OnPositionChanging(ref PositionChangingEventArgs e)
        {
            PositionChangingEventHandler handler = PositionChanging;

            handler?.Invoke(this, e);
        }