开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜