예제 #1
0
        public override void OnApplyTemplate()
        {
            if (_popup != null)
            {
                _popup.Closed -= popup_Closed;
            }
            if (_button != null)
            {
                _button.Checked -= button_Checked;
            }

            _popup     = GetTemplateChild("popup") as Popup;
            _button    = GetTemplateChild("button") as ToggleButton;
            _combo     = GetTemplateChild("nameCombo") as ComboBox;
            _typeCombo = GetTemplateChild("typeCombo") as MyComboBox;

            if (_button != null)
            {
                _button.Checked += button_Checked;
            }
            if (_popup != null)
            {
                _popup.Closed += popup_Closed;
            }
            if (_combo != null)
            {
                _combo.PreviewKeyDown += _combo_PreviewKeyDown;
            }

            // Circumvent a bug in WPF: this binding is already declared in XAML but WPF removes it for piercing boxes that are not loaded at the start of the application.
            _typeCombo.SetBinding(MyComboBox.SelectedValueProperty, "Type");
        }
예제 #2
0
        static void OnItemsSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            MyComboBox box = (MyComboBox)obj;

            box.PopulateInternalItems();
            box.AddUnknownItem();
        }
예제 #3
0
        static void OnSelectedValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            MyComboBox box = (MyComboBox)obj;

            box.AddUnknownItem();
        }