tags:

views:

70

answers:

1

I tried to place a TextBlock inside a ScrollViewer, and the scroll bar shows up correctly, but I cannot seem to make it automatically scroll down when the Text property of the TextBlock is updated. Here's the relevant part of the XAML:

<ScrollViewer>
  <TextBlock FontFamily="Consolas"
    Text="{Binding Current.Current.Discussion}"
    TextWrapping="Wrap" />
</ScrollViewer>

Help would be greatly appreciated, thanks!

+2  A: 

By default, the behavior you get is that the scroll bars will adjust to the amount of text in the textblock, but the viewer will be showing the top of the text. To refresh that properly do this:

scrollViewer.UpdateLayout();
scrollViewer.ScrollToVerticalOffset(txtBlock.ActualHeight);
Gustavo Cavalcanti
Thanks! I couldn't find an event which would fire when the Text property changed, so I decided to use a TextBox instead.
forest.belton