Exemple #1
0
        /// <summary>
        /// Caled when the <see cref="Items"/> property changes.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected virtual void ItemsChanged(PerspexPropertyChangedEventArgs e)
        {
            var incc = e.OldValue as INotifyCollectionChanged;

            if (incc != null)
            {
                incc.CollectionChanged += ItemsCollectionChanged;
            }

            var newValue = e.NewValue as IEnumerable;

            if (newValue == null || newValue.Count() == 0)
            {
                Classes.Add(":empty");
            }
            else
            {
                Classes.Remove(":empty");
            }

            incc = newValue as INotifyCollectionChanged;

            if (incc != null)
            {
                incc.CollectionChanged += ItemsCollectionChanged;
            }
        }
Exemple #2
0
        /// <summary>
        /// Called when the <see cref="INotifyCollectionChanged.CollectionChanged"/> event is
        /// raised on <see cref="Items"/>.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        protected virtual void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            var collection = sender as ICollection;

            if (collection.Count == 0)
            {
                Classes.Add(":empty");
            }
            else
            {
                Classes.Remove(":empty");
            }
        }
Exemple #3
0
        /// <inheritdoc/>
        protected override void OnPointerReleased(PointerEventArgs e)
        {
            base.OnPointerReleased(e);

            e.Device.Capture(null);
            Classes.Remove(":pressed");
            e.Handled = true;

            if (ClickMode == ClickMode.Release && Classes.Contains(":pointerover"))
            {
                RaiseClickEvent();
            }
        }
Exemple #4
0
        /// <summary>
        /// Subscribes to an <see cref="Items"/> collection.
        /// </summary>
        /// <param name="items"></param>
        private void SubscribeToItems(IEnumerable items)
        {
            if (items == null || items.Count() == 0)
            {
                Classes.Add(":empty");
            }
            else
            {
                Classes.Remove(":empty");
            }

            var incc = items as INotifyCollectionChanged;

            if (incc != null)
            {
                incc.CollectionChanged += ItemsCollectionChanged;
            }
        }