using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TextBoxSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //在TextBox控件中打印选取文字
            txtMessage1.Text = txtMessage.SelectedText;
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //利用程序选取所有字符
            txtMessage.SelectAll();
            txtMessage.Focus();

            //在TextBox控件中打印选取文字
            txtMessage2.Text = txtMessage.SelectedText;
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            //利用程序选取前10个字符
            txtMessage.SelectionStart = 0;
            txtMessage.SelectionLength = 10;
            txtMessage.Focus();
            
            //在TextBox控件中打印选取文字
            txtMessage3.Text = txtMessage.SelectedText;
        }
    }
}
