Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've added a textbox and scroll bar to a control in WPF. When I'm clicking on the bottom arrow of the scroll bar, the textbox scrolls to the end.

My problem is: I want to scroll the textbox with the Scrollbar line by line.

How can I do this?

What I have tried:

C#
private void DisclaimerScrollBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
      {

          txbDisclaimerDesc.Focus();
          if (e.NewValue > e.OldValue)
          {
              for (int i = 0; i < txbDisclaimerDesc.LineCount - 1; i++)
              {
                  txbDisclaimerDesc.ScrollToLine(i);
              }
          }
          else
              txbDisclaimerDesc.ScrollToHome();
      }
Posted
Updated 30-Nov-16 7:27am

1 solution

That's because there's only one line (that probably wraps) in the textbox.

You shouldn't have to do anything special for this to work. Simply set VerticalScrollBarVisibility="Auto" for the textbox in your xaml, and it will do what it needs to do.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900