示例#1
0
        /// <summary>
        /// Checks if other was selected and handles.
        /// </summary>
        /// <param name="sender">The split list box.</param>
        /// <param name="e">Selected Event Args.</param>
        private void SplitListBoxItem_Selected(object sender, SelectedEventArgs e)
        {
            if (e.SelectedItem == this.OtherItem)
            {
                e.Handled = true;
                this.ConfirmedSelectedItem = null;
                SplitListBoxItem splitListBoxItem = sender as SplitListBoxItem;
                splitListBoxItem.IsSelectedValue = false;

                if (this.OtherItemsSource != null)
                {
                    this.ShowOtherItems = true;
                }

                if (this.OtherSelected != null)
                {
                    this.OtherSelected(this, EventArgs.Empty);
                }
            }
            else
            {
                this.SelectedItem          = e.SelectedItem;
                this.ConfirmedSelectedItem = e.SelectedItem;
                if (this.ConfirmedSelectedItem != null)
                {
                    this.ScrollIntoView(this.ConfirmedSelectedItem);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Updates the computed header visibility.
        /// </summary>
        /// <param name="obj">The headered list box item.</param>
        /// <param name="args">Dependency Property Changed Event Args.</param>
        private static void Header_Changed(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            SplitListBoxItem splitListBoxItem = obj as SplitListBoxItem;

            if (args.NewValue != null)
            {
                splitListBoxItem.SetValue(SplitListBoxItem.ComputedHeaderVisibilityProperty, Visibility.Visible);
            }
            else
            {
                splitListBoxItem.SetValue(SplitListBoxItem.ComputedHeaderVisibilityProperty, Visibility.Collapsed);
            }
        }
 /// <summary>
 /// SplitListBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitListBoxItem">The split list box item instance.</param>
 /// <param name="parent">The parent selector peer.</param>
 public SplitListBoxItemAutomationPeer(SplitListBoxItem splitListBoxItem, SelectorAutomationPeer parent)
     : base(splitListBoxItem, parent)
 {
     this.splitListBoxItem = splitListBoxItem;
     this.parent           = parent;
 }
 /// <summary>
 /// SplitListBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitListBoxItem">The split list box item instance.</param>
 /// <param name="parent">The parent selector peer.</param>
 public SplitListBoxItemAutomationPeer(SplitListBoxItem splitListBoxItem, SelectorAutomationPeer parent)
     : base(splitListBoxItem, parent)
 {
     this.splitListBoxItem = splitListBoxItem;
     this.parent = parent;
 }
示例#5
0
        /// <summary>
        /// Prepares the split list box item.
        /// </summary>
        /// <param name="element">The split list box item.</param>
        /// <param name="item">The item object.</param>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            if (this.verticalScrollBar == null)
            {
                this.verticalScrollBar = this.GetVerticalScrollBar(element) as ScrollBar;
                if (this.verticalScrollBar != null)
                {
                    this.verticalScrollBar.Scroll       += new ScrollEventHandler(this.VerticalScrollBar_Scroll);
                    this.verticalScrollBar.ValueChanged += new RoutedPropertyChangedEventHandler <double>(this.VerticalScrollBar_ValueChanged);
                }
            }

            SplitListBoxItem splitListBoxItem = element as SplitListBoxItem;

            if (splitListBoxItem != null)
            {
                splitListBoxItem.ParentSplitListBox = this;
                splitListBoxItem.ItemSelected      += new EventHandler <SelectedEventArgs>(this.SplitListBoxItem_Selected);

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

                if (this.ItemHeaderTemplate != null)
                {
                    splitListBoxItem.HeaderTemplate = this.ItemHeaderTemplate;
                }

                if (this.itemHeadersByItem.ContainsKey(item))
                {
                    splitListBoxItem.Header = this.itemHeadersByItem[item];
                    this.itemHeadersByItem.Remove(item);
                }

                if (this.shortcutKeysByItem.ContainsKey(item))
                {
                    splitListBoxItem.ShortcutKeyText        = ShortcutKeyHelper.ShortcutKeyPrefix + ShortcutKeyHelper.GetKeyAsString(this.shortcutKeysByItem[item]);
                    splitListBoxItem.ShortcutKeyTextOpacity = this.showingShortcutKeys ? 1.0 : 0.0;
                }

                if (this.splitItems.Contains(item))
                {
                    splitListBoxItem.SplitBorderThickness = this.SplitBorderThickness;
                    splitListBoxItem.SplitBorderBrush     = this.SplitBorderBrush;
                }

                if (item == this.OtherItem && this.OtherItemTemplate != null)
                {
                    splitListBoxItem.ContentTemplate = this.OtherItemTemplate;
                }
                else if (item == this.CustomValueItem && this.CustomValueItemTemplate != null)
                {
                    splitListBoxItem.ContentTemplate = this.CustomValueItemTemplate;
                }

                this.UpdateItemBackgrounds();
            }
        }
示例#6
0
        /// <summary>
        /// Updates the visual state of the control.
        /// </summary>
        /// <param name="obj">The CascadingListBoxItem.</param>
        /// <param name="args">Dependency Property Changed Event Args.</param>
        private static void IsSelectedValue_Changed(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            SplitListBoxItem splitListBoxItem = obj as SplitListBoxItem;

            splitListBoxItem.UpdateVisualState(true);
        }
 /// <summary>
 /// SplitListBoxItemAutomationPeer constructor.
 /// </summary>
 /// <param name="splitListBoxItem">The split list box item instance.</param>
 public SplitListBoxItemAutomationPeer(SplitListBoxItem splitListBoxItem)
     : base(splitListBoxItem)
 {
     this.splitListBoxItem = splitListBoxItem;
 }