wpf combox光标定位

private void text_PreviewKeyDown(object sender, KeyEventArgs e)
        {
          var cb = (ComboBox)sender;
            cb.IsDropDownOpen = true;
            TextBox textBox = (TextBox)cb.Template.FindName("PART_EditableTextBox", cb);
            //每次填写后  光标定位在文本的后面
            textBox.SelectionStart = textBox.Text.Length;

        }

 

你可能感兴趣的:(WPF)