WPF C# Tutorial

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="TextBoxTest" Height="325" Width="390">
  
    
      
      
    

                 SelectionChanged="txt_SelectionChanged"  
             SpellCheck.IsEnabled="True">this is a test
  

//File:Window.xaml.cs
using System;
using System.Collections.Generic;
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.Shapes;
namespace ClassicControls
{
    public partial class TextBoxTest : System.Windows.Window
    {
        public TextBoxTest()
        {
            InitializeComponent();
        }
        private void txt_SelectionChanged(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(txt.SelectionStart);
            Console.WriteLine(txt.SelectionLength);
            Console.WriteLine(txt.SelectedText);
        }
    }
}