コード例 #1
0
        private static void ComboBoxOnDropDownOpened(object sender, EventArgs eventArgs)
        {
            var comboBox        = (ComboBox)sender;
            var cloneTextBox    = comboBox.Template.FindName("EditableTextBoxClone", comboBox) as TextBox;
            var originalTextBox = comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox;

            if (cloneTextBox != null && originalTextBox != null)
            {
                var managedOverlayInfo = new ComboBoxAssistManagedOverlayInfo(comboBox, originalTextBox, cloneTextBox);

                cloneTextBox.PreviewKeyDown      += CloneTextBoxOnPreviewKeyDown;
                cloneTextBox.SelectionLength      = originalTextBox.SelectionLength;
                cloneTextBox.SelectionStart       = originalTextBox.SelectionStart;
                originalTextBox.SelectionChanged += OriginalTextBoxOnSelectionChanged;
                SetManagedOverlayInfo(comboBox, managedOverlayInfo);
                SetManagedOverlayInfo(originalTextBox, managedOverlayInfo);
                SetManagedOverlayInfo(cloneTextBox, managedOverlayInfo);
            }

            cloneTextBox?.Dispatcher.BeginInvoke(new Action(() =>
            {
                cloneTextBox.Focus();
            }));
        }
コード例 #2
0
        private static void ComboBoxOnDropDownOpened(object sender, EventArgs eventArgs)
        {
            var comboBox = (ComboBox)sender;
            var cloneTextBox = comboBox.Template.FindName("EditableTextBoxClone", comboBox) as TextBox;
            var originalTextBox = comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox;

            if (cloneTextBox != null && originalTextBox != null)
            {
                var managedOverlayInfo = new ComboBoxAssistManagedOverlayInfo(comboBox, originalTextBox, cloneTextBox);

                cloneTextBox.PreviewKeyDown += CloneTextBoxOnPreviewKeyDown;
                cloneTextBox.SelectionLength = originalTextBox.SelectionLength;
                cloneTextBox.SelectionStart = originalTextBox.SelectionStart;
                originalTextBox.SelectionChanged += OriginalTextBoxOnSelectionChanged;
                SetManagedOverlayInfo(comboBox, managedOverlayInfo);
                SetManagedOverlayInfo(originalTextBox, managedOverlayInfo);
                SetManagedOverlayInfo(cloneTextBox, managedOverlayInfo);
            }

            cloneTextBox?.Dispatcher.BeginInvoke(new Action(() =>
            {
                cloneTextBox.Focus();
            }));
        }