开发者

WPF- Is it possible to add an OnVerticalOffsetChanged event to a custom textbox?

开发者 https://www.devze.com 2022-12-27 04:16 出处:网络
Is th开发者_高级运维ere any way for me to do this?You can tell when the VerticalOffset changes by adding a handler to the ScrollViewer.ScrollChanged event to your TextBox. Something like this:

Is th开发者_高级运维ere any way for me to do this?


You can tell when the VerticalOffset changes by adding a handler to the ScrollViewer.ScrollChanged event to your TextBox. Something like this:

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

The TextBox uses a ScrollViewer internally, so it's ScrollChanged event will bubble up to the TextBox (where you can handle it). The event arguments include information about what changed, such as the 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));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号