Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How do I reliably get the view port top edge from a IWpfTextView?

$
0
0

I've been using IWpfTextView.ViewportTop and it works as long as the user scrolls around. However when the view is changed dramatically, the ViewportTop gets reset to zero. (From the docs on ViewportTop: "The value can be either positive or negative. When the viewport layout is only partially changed, ViewportTop is increased or decreased by the number of pixels up or down that the view has been scrolled.When the viewport layout is completely changed (such that all of the lines of the previous layout are changed), ViewportTop is reset to 0.0.") So, for example, when doing a Ctrl-End, Ctrl-Home, or Ctrl-G such that the view pops to a place in the file, the ViewportTop is reset to zero.

How, then, do I adjust something like mouse coordinates (e.GetPosition(view.VisualElement)) to proper text view coordinates if ViewportTop can be zero when not scrolled to the top of the file? I can't seem to see another method/property that will provide the information. Also, if anyone knows why ViewportTop is implemented this way, I'd love to know. It doesn't make much sense to me.


Viewing all articles
Browse latest Browse all 4410

Trending Articles