我在flowdocument滚动查看器中显示flowdocument的内容时遇到了一些问题。我创建了一个泛型列表,其中包含一个包含int、string和flowdocument的类。
在WPF列表框中,我试图在滚动查看器中的按钮旁边显示flowdocument。我使用从WPF窗口构造函数调用的以下函数来填充列表框
private void populateListBox()
{
foreach(Element el in _notesList)
{
StackPanel sp = new StackPanel();
sp.Orientation = Orientation.Horizontal;
Button b = new Button();
b.Content = el._theID;
sp.Children.Add(b);
FlowDocumentScrollViewer fdsv = new FlowDocumentScrollViewer();
fdsv.MinWidth = 400;
fdsv.Document = el._theDoc;
sp.Children.Add(fdsv);
ListBoxItem lbi = new ListBoxItem();
lbi.Content = sp;
noteList.Items.Add(lbi);
}
}但是代码不起作用。没有错误,但是滚动查看器在列表框中是空白的。我还尝试将类存储在ObservableList中并绑定到文档属性,但也不起作用。
你知道是怎么回事吗?
发布于 2016-04-11 11:05:35
不要紧。我想通了。
在程序执行的后面,我在foreach语句中将flowdocument块复制到一个合并的文档中。即使使用Blocks.ToList(),这也不起作用。我最终找到了一种将文档内容复制到另一个文档here的方法。
https://stackoverflow.com/questions/36527106
复制相似问题