//设置已选文本提示 private void TextBox_SelectionChanged(object sender, RoutedEventArgs e) { System.Windows.Controls.TextBox textBox = sender as System.Windows.Controls.TextBox; int row = textBox.GetLineIndexFromCharacterIndex(textBox.CaretIndex); int col = textBox.CaretIndex - textBox.GetCharacterIndexFromLineIndex(row); txtStatus_row.Text = $"行:{ row + 1}"; txtStatus_col.Text = $"列:{ col + 1}";; txtStatus_select.Text = "已选:" + textBox.SelectionLength; }