TextBox的SelectionChanged事件及TextBox的Select属性

效果就是选取text后会显示选取的字符内容,以及在当前TextBox中这些内容的位置。

监听SelectionChanged事件

        private void txt_SelectionChanged(object sender, RoutedEventArgs e)
        {
            if (txtSelection == null) return;
            txtSelection.Text = String.Format(
            "Selection from {0} to {1} is "{2}"",
            txt.SelectionStart, txt.SelectionLength, txt.SelectedText);
        }    
原文地址:https://www.cnblogs.com/yingzilovexiaoxiong/p/14320333.html