Implementing footnotes in a WPF FlowDocument

What would be the best approach to display footnotes for FlowDocument content in a FlowDocumentPageViewer?

My first thought was to have the contents of the footnote follow immediately after the footnote anchor within the FlowDocument, with the footnote content formatted as a Figure with VerticalAnchor set to PageBottom.

This works great, but when there are multiple footnotes on a page, the footnotes are stacked in reverse order, ie the first footnote is all the way on the bottom, with subsequent footnotes being stacked on top of it.

Another difficulty with this approach is that long footnotes will not be allowed to span pages, as Figure does not allow that.

A more extreme approach would be to do the same in reverse - format the regular text as stacked figures with VerticalAnchor set to PageTop, and let the footnotes flow on the bottom. However, paragraphs (which tend to be longer than footnotes) will now not span pages.

What other approaches can I try?

Ideally I would like to display the footnotes as they would appear in print (ie on the bottom of the page they are relevant to), but I am open to other approaches.

This is for a reader app for specialized academic content, where long and frequent footnotes are the norm and should be part of the reading experience. For this reason I do not want to use endnotes, and prefer footnotes displayed on the bottom of each page.


I spent a while looking at this and have to agree that there doesn't seem to be a "nice and easy" way of doing it.

I tried deriving my own wrapper classes from the Floater and Figure classes but it gets very convoluted very quickly as pagination is horrid (at least for me) to work out. The problem with these is that the Figure allows itself to be anchored to a parent in XAML, whereas the Floater has all the nice functionality you need - like pagination - but it can't be anchored anywhere... bit of a Catch 22 really, even in .NET 4.0.

I found two links here and here that might help. The first one may seem a bit irrelevant at first glance but have a look at the code and you should get the idea) I played around with the code and the general idea works. It defines a wrapper class around the DocumentPaginator and therefore allows you to control the actual pagination.

Hopefully that helps a bit anyway.

链接地址: http://www.djcxy.com/p/1434.html

上一篇: 用于.NET的浏览器模拟器API

下一篇: 在WPF FlowDocument中实现脚注