Just wondering whether anybody has tried to hack into WPF DocumentViewer
in order to make it more useful. I've spent almost a week already trying to create more powerful API for this control based on it's methods which I extract using reflection.
Everybody knows how to get selected text from document viewer via reflection but my task is more complicated. Selected text has End
and Start
properties which return ITextPointers
. Also I have a collection of GlyphRuns extracted using this code. And now finally I want to find out which GlyphRun
contains selection start.
So I want to know how to convert ITextPointers
into GlyphRuns
and vice versa. I understand that they do not have 1:1 relationship. This control with closed API and last week spent in Reflector doesn't let me sleep well. I hope maybe somebody tried to do it before or seen code samples and will be able to guide me through these jungles.
I would recommend that you abandon this approach. Doing lots of private reflection like this is not something you should be basing production code on, its very brittle and downright forbidden in some contexts. Frankly, you're better off finding a 3rd party control that suits your needs such as www.infragistics.com
Or if that's not an option you can probably create your own control in the amount of time you'll have to sink into getting this to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With