WPF. Is it possible to add the OnVerticalOffsetChanged event to a custom textbox?

Do I have a way to do this?

+2


a source to share


1 answer


You can find out when the VerticalOffset value changes by adding a ScrollViewer.ScrollChanged event handler to your TextBox. Something like that:

<TextBox AcceptsReturn="True" ScrollViewer.ScrollChanged="TextBox_ScrollChanged" />

      



The TextBox uses the ScrollViewer internally, so the ScrollChanged event will bubble up to the TextBox (where you can handle it). Event arguments include information about what has changed, such as VerticalChange (the amount that the control has scrolled vertically).

private void TextBox_ScrollChanged(object sender, ScrollChangedEventArgs e) {
    System.Diagnostics.Debug.WriteLine(string.Format("************ {0}", e.VerticalChange));
}

      

+6


a source







All Articles