views:

115

answers:

1

I need to get the maximum value of a richtextbox's vertical scrollbar so that I can scroll to a percentage of the scrollbar's maximum value.

+1  A: 

The way I've done it, I have the RichTextBox inside of a ScrollViewer, e.g.

<ScrollViewer Name="sv">
  <RichTextBox>
    <FlowDocument>
      <Paragraph />
    </FlowDocument>
  </RichTextBox>
</ScrollView>

Then from code-behind, you can read the value of sv.ExtentHeight, take a percentage of it, and then call sv.ScrollToVerticalOffset() to move the scrollbar to that position.

Dave