Inheritance: System.Windows.Controls.ContentControl
Beispiel #1
0
        /// <summary>
        /// Called when an Item's IsSelected property has changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnLongListMultiSelectorItemIsSelectedChanged(object sender, EventArgs e)
        {
            LongListMultiSelectorItem item = sender as LongListMultiSelectorItem;

            if (item != null)
            {
                object content = item.Content;
                if (content != null)
                {
                    if (item.IsSelected)
                    {
                        // Check if the item is already in the SelectedItems
                        // collection, otherwise a double-add will happen.
                        if (!SelectedItems.Contains(content))
                        {
                            SelectedItems.Add(content);
                        }
                    }
                    else
                    {
                        SelectedItems.Remove(content);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when an item is realized :
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnInnerSelectorItemRealized(object sender, ItemRealizationEventArgs e)
        {
            if (e.ItemKind == LongListSelectorItemKind.Item)
            {
                int childrenCount = VisualTreeHelper.GetChildrenCount(e.Container);
                if (childrenCount > 0)
                {
                    LongListMultiSelectorItem llItem = VisualTreeHelper.GetChild(e.Container, 0) as LongListMultiSelectorItem;
                    if (llItem != null)
                    {
                        ConfigureItem(llItem);

                        // Check if item should be selected
                        llItem.IsSelected         = _selectedItems.Contains(llItem.Content);
                        llItem.IsSelectedChanged += OnLongListMultiSelectorItemIsSelectedChanged;
                        llItem.GotoState(IsSelectionEnabled ? LongListMultiSelectorItem.State.Opened : LongListMultiSelectorItem.State.Closed);

                        _realizedItems.Add(llItem.WR);
                    }
                }
            }
            if (ItemRealized != null)
            {
                ItemRealized(sender, e);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Configure an item's template according to the current state
        /// </summary>
        /// <param name="item"></param>
        internal void ConfigureItem(LongListMultiSelectorItem item)
        {
            if (item != null)
            {
                item.ContentTemplate = ItemTemplate;

                if (ItemContainerStyle != null)
                {
                    if (item.Style != ItemContainerStyle)
                    {
                        item.Style = ItemContainerStyle;
                    }
                }
                else if (LayoutMode == LongListSelectorLayoutMode.Grid)
                {
                    if (item.Style != DefaultGridItemContainerStyle)
                    {
                        item.Style = DefaultGridItemContainerStyle;
                    }
                }
                else
                {
                    if (item.Style != DefaultListItemContainerStyle)
                    {
                        item.Style = DefaultListItemContainerStyle;
                    }
                }
                if ((ItemInfoTemplate != null) && (item.ContentInfoTemplate != ItemInfoTemplate))
                {
                    item.SetBinding(LongListMultiSelectorItem.ContentInfoProperty, new Binding());
                    item.ContentInfoTemplate = ItemInfoTemplate;
                }
            }
        }
        /// <summary>
        /// Handles the change of the HintPanelHeight property
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnHintPanelHeightPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            LongListMultiSelectorItem This = sender as LongListMultiSelectorItem;

            if (This != null)
            {
                This.OnHintPanelHeightChanged();
            }
        }
        /// <summary>
        /// Called then the property is changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void OnIsSelectedPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            LongListMultiSelectorItem This = sender as LongListMultiSelectorItem;

            if (This != null)
            {
                This.OnIsSelectedChanged();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Called when an Item's IsSelected property has changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnLongListMultiSelectorItemIsSelectedChanged(object sender, EventArgs e)
        {
            LongListMultiSelectorItem item = sender as LongListMultiSelectorItem;

            if (item != null)
            {
                object content = item.Content;
                if (content != null)
                {
                    if (item.IsSelected)
                    {
                        SelectedItems.Add(content);
                    }
                    else
                    {
                        SelectedItems.Remove(content);
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Disconnects an item when it is unrealized
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnInnerSelectorItemUnrealized(object sender, ItemRealizationEventArgs e)
        {
            if (e.ItemKind == LongListSelectorItemKind.Item)
            {
                int childrenCount = VisualTreeHelper.GetChildrenCount(e.Container);
                if (childrenCount > 0)
                {
                    LongListMultiSelectorItem llItem = VisualTreeHelper.GetChild(e.Container, 0) as LongListMultiSelectorItem;
                    if (llItem != null)
                    {
                        llItem.IsSelectedChanged -= OnLongListMultiSelectorItemIsSelectedChanged;

                        _realizedItems.Remove(llItem.WR);
                    }
                }
            }
            if (ItemUnrealized != null)
            {
                ItemUnrealized(sender, e);
            }
        }