在 WPF FlowDocument 中重复数据绑定项
我在 WPF 中有一个如下所示的流文档:
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Paragraph FontFamily="Georgia">
<StackPanel>
<TextBlock Text="{Binding Path=Title}"/>
<TextBlock Text="{Binding Path=AssignedTo}"/>
</StackPanel>
</Paragraph>
</FlowDocument>
我不想为 DataContext 提供一个具有 Title 和AssignedTo 属性的类,而是为其提供该类的列表,并让流文档显示其中每个对象。有人可以告诉我如何在流程文档中形成 XAML 来执行此操作吗?
I have a flowdocument in WPF that looks like this:
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Paragraph FontFamily="Georgia">
<StackPanel>
<TextBlock Text="{Binding Path=Title}"/>
<TextBlock Text="{Binding Path=AssignedTo}"/>
</StackPanel>
</Paragraph>
</FlowDocument>
instead of giving the DataContext a class with the Title and AssignedTo property, I would like to give it a List of that class and have the flowdocument show each of them objects. Can someone tell me how to form the XAML in the flowdocument to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谁知道呢,也许像下面的代码示例一样简单对您有用,Ajma:
如果不是,您可以随时创建自己的附加属性,并在属性更改通知中执行您可以想象的任何操作。这是一个带有 Span 控件的小示例:
CS:
XAML
希望这会有所帮助:)
Who knows, maybe as simple as the following code sample will work for you, Ajma:
If it's not, you can always create your own attached property and do whatever you can imagine inside property changed notification. Here is a small sample with Span control:
CS:
XAML
Hope this helps :)