示例#1
0
        /// <summary>
        /// The on value changed.
        /// </summary>
        /// <param name="dependencyObject"> The dependency object. </param>
        /// <param name="e"> The Event Arguments. </param>
        private static void OnValueChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            ElasticListBoxItem listBoxItem = (ElasticListBoxItem)dependencyObject;
            ElasticListBox     listBox     = listBoxItem.ParentListBox;

            // Update the total.
            var items = listBox.Items
                        .Cast <object>()
                        .Select(x => listBoxItem.ParentListBox.ItemContainerGenerator.ContainerFromItem(x))
                        .Where(x => x != null)
                        .Cast <ElasticListBoxItem>();

            listBox.Total = items.Sum(x => x.Value);

            // Update the percentage.
            foreach (var item in items)
            {
                if (listBox.Total == 0D)
                {
                    item.Percentage        = 0D;
                    item.PercentageOpacity = listBoxItem.MinOpacity;
                }
                else
                {
                    item.Percentage        = item.Value / listBox.Total;
                    item.PercentageOpacity = Math.Max(listBoxItem.MinOpacity, item.Percentage);
                }
            }

            listBox.ResizeItems();
        }
示例#2
0
        /// <summary>
        /// The on is highlighted changed.
        /// </summary>
        /// <param name="dependencyObject"> The dependency object. </param>
        /// <param name="e"> The Event Arguments. </param>
        private static void OnIsHighlightedChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            ElasticListBoxItem listBoxItem = (ElasticListBoxItem)dependencyObject;
            ElasticListBox     listBox     = listBoxItem.ParentListBox;

            listBox.ResizeItems();
        }
示例#3
0
        /// <summary>
        /// Gets the height of the specified list box item.
        /// </summary>
        /// <param name="listBoxItem">The list box item.</param>
        /// <returns>The height.</returns>
        private double GetHeight(ElasticListBoxItem listBoxItem)
        {
            double height;

            if (listBoxItem.IsHighlighted)
            {
                height = 0;
            }
            else
            {
                height = listBoxItem.MinHeight;
            }

            return(height);
        }