Multiline Textbox : Display current line/character index in statusbar
问题 I have a multiline textbox where the user can edit text. In a statusbar I'd like to show the current line / character index. I know I can get the CaretIndex, and use GetLineIndexFromCharacterIndex to get the line-index. But how would I go about binding that into the statusbar ? 回答1: I'd use an attached behavior for that. The behavior can listens to changes with SelectionChanged and update two attached properties CaretIndex and LineIndex accordingly. <TextBox Name="textBox" AcceptsReturn="True