tags:

views:

35

answers:

1

Hi,

I was wondering if there is anyway to check if the up arrow or the bottom arrow of a wpf scroll viewer is clicked. I am trying to do it within a wpf textbox but, I want it to snap to the next line of a text instead of displaying partial text.

So, the way for me to do this is when up/ or down is clicked. i would say textBox.lineup/linedown.

but I also need to know which component is clicked in order to do so. Thanks in advance!

-Kevin

A: 

You can use ScrollChanged event in ScrollViewer as below

<ScrollViewer ScrollChanged="ScrollViewer_ScrollChanged">

In code you can get the verticalOffSet value.

 private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
    {
        double verticalOffSet = e.VerticalOffset;
        ...
    }
Ragunathan
Actually. After trying this. Seems like it gets called anytime anything changes...
Kevin
Basically this method will be called any changes in Scrollviewer horizontalOffset or verticall offset.
Ragunathan