views:

262

answers:

2

In Visual Studio's output window, you can position your text caret at the end of the output so that the textbox scrolls down automatically when new text is logged. And when the caret is not at the end, it won't scroll down. I would like to mimic this with a WPF TextBox.

I was able to do it, but only if the TextBox is not read-only. That is because I need a caret, and none is displayed when you have a read-only TextBox.

The problem is my textbox is editable (with copy/cut/paste commands and typing), but I don't want to.

Is there a clean solution? I would prefer not to block all keys since I have CommandBindings that need to work when the TextBox is focused.

Thanks

A: 

I guess you wont get around sublassing the TextBox and block all keyboardinput that would change the text.

bitbonk
+1  A: 

Apparently, enough people had the same problem for them to add a property just for this issue. If you can set your project to use .NET 4.0, the TextBox has a new property IsReadOnlyCaretVisible.

omdsmr
Does not really help him, but good to know.. +1 for you ;)
Arcturus