Esempio n. 1
0
        /// <summary>
        /// Sets the selected item to the clicked item.
        /// </summary>
        /// <param name="sender">The cascading list box item.</param>
        /// <param name="e">Mouse Button Event Args.</param>
        private void CascadingListBoxItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CascadingListBoxItem cascadingListBoxItem = sender as CascadingListBoxItem;

            if (cascadingListBoxItem != null)
            {
                this.SelectedItem = cascadingListBoxItem.Content;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the currently focused item.
        /// </summary>
        /// <param name="sender">The cascading list box item.</param>
        /// <param name="e">Routed Event Args.</param>
        private void CascadingListBoxItem_GotFocus(object sender, RoutedEventArgs e)
        {
            CascadingListBoxItem cascadingListBoxItem = sender as CascadingListBoxItem;

            if (cascadingListBoxItem != null)
            {
                this.focusedItem = cascadingListBoxItem.Content;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Prepares the container.
        /// </summary>
        /// <param name="element">The list box item.</param>
        /// <param name="item">The item object.</param>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            CascadingListBoxItem cascadingListBoxItem = element as CascadingListBoxItem;

            if (cascadingListBoxItem != null)
            {
                cascadingListBoxItem.GotFocus     += new RoutedEventHandler(this.CascadingListBoxItem_GotFocus);
                cascadingListBoxItem.LostFocus    += new RoutedEventHandler(this.CascadingListBoxItem_LostFocus);
                cascadingListBoxItem.ItemSelected += new EventHandler <SelectedEventArgs>(this.CascadingListBoxItem_Selected);

#if !SILVERLIGHT
                cascadingListBoxItem.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(this.CascadingListBoxItem_PreviewMouseLeftButtonDown);
#endif

                if (!this.containersByItem.ContainsKey(item))
                {
                    this.containersByItem.Add(item, cascadingListBoxItem);
                }
                else
                {
                    this.containersByItem[item] = cascadingListBoxItem;
                }

#if !SILVERLIGHT
                if (this.IsExpanded && this.IsFocused && (this.ConfirmedSelectedItem == item || this.SelectedItem == item))
                {
                    cascadingListBoxItem.Focus();
                }
#endif
                if (item == this.ConfirmedSelectedItem)
                {
                    cascadingListBoxItem.IsSelectedValue = true;
                }
            }
        }