前:
12 3 4 5
后:
1 private void TextBox_SelectionChanged(object sender, RoutedEventArgs e)2 {3 TextBox textBox = sender as TextBox;4 txtStatus.Text = "Selection starts at character #" + textBox.SelectionStart + Environment.NewLine;5 txtStatus.Text += "Selection is " + textBox.SelectionLength + " character(s) long" + Environment.NewLine;6 txtStatus.Text += "Selected text: '" + textBox.SelectedText + "'";7 }