private static void comboBoxItem_Loaded(object sender, RoutedEventArgs e) { FrameworkElement element = (FrameworkElement)sender; MultiSelectComboBox comboBox = GetComboBox(element); if (comboBox?.DisplayBindingPath != null) { element.SetBinding(CheckBox.ContentProperty, new Binding { Path = new PropertyPath(comboBox.DisplayBindingPath) }); comboBox.UpdateSelectedContainer(element as ToggleButton, element.GetVisualParent <MultiSelectComboBoxItem>(), true); } }
private static void targetElement_Loaded(object sender, RoutedEventArgs e) { TextBlock targetElement = (TextBlock)sender; targetElement.Loaded -= new RoutedEventHandler(targetElement_Loaded); MultiSelectComboBox comboBox = targetElement.GetVisualParent <MultiSelectComboBox>(); if (comboBox != null) { targetElement.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("SelectedItemsContents"), Converter = new MultiSelectComboBoxConverter(), Source = comboBox, ConverterParameter = comboBox.DisplayBindingPath }); } }
/// <summary> /// Initializes a new instance of MultiSelectComboBoxItem class /// </summary> /// <param name="parent">parent comboBox</param> public MultiSelectComboBoxItem(MultiSelectComboBox parent) { ParentComboBox = parent; }