/// <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(); } }
/// <summary> /// Adds a shortcut key to an item. /// </summary> /// <param name="item">The item to add the key too.</param> /// <param name="key">The short cut key.</param> public void AddItemShortcutKey(object item, Key?key) { if (key.HasValue && item != null) { if (this.itemsByShortcutKey.ContainsKey(key.Value)) { this.itemsByShortcutKey[key.Value] = item; } else { this.itemsByShortcutKey.Add(key.Value, item); } if (this.shortcutKeysByItem.ContainsKey(item)) { this.shortcutKeysByItem[item] = key.Value; } else { this.shortcutKeysByItem.Add(item, key.Value); } if (this.containersByItem.ContainsKey(item)) { this.containersByItem[item].ShortcutKeyText = ShortcutKeyHelper.ShortcutKeyPrefix + ShortcutKeyHelper.GetKeyAsString(key.Value); this.containersByItem[item].ShortcutKeyTextOpacity = this.showingShortcutKeys ? 1.0 : 0.0; } } }