tI've got a Textbox inside a Scrollviewer:
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<TextBox IsReadOnly="True" TextWrapping="Wrap" Text="{Binding Messages, Converter={StaticResource TimedStringListToStringConverter}, UpdateSourceTrigger=PropertyChanged}"/>
</ScrollViewer>
I want to set the vertical scrollbar to bottom only when i manually drag it to the bottom, otherwise it mustn't move from its position.
Ideas?
To achieve what you want (scrolling to the end only when you've already manually scrolled down there) and using the TextBox's own ScrollViewer, you just have to handle the
TextChanged
event and in code-behind do this:If you need to use the extra ScrollViewer around the TextBox, then just use that ScrollViewer's
ExtentHeight
,ViewportHeight
andVerticalOffset
, and call that ScrollViewer'sScrollToBottom
(instead of TextBox'sScrollToEnd
).Keep in mind that the text input caret position is not changing, so if you try to enter text manually, the scroll is gonna jump to wherever the caret is.