私のMVVMWPFアプリケーションでは、データバインドされたフロードキュメントを使用しています。ここで説明する手法を使用して、データをフロードキュメントにバインドできるようにしました。フロードキュメントは、ビューモデルのパブリックプロパティにバインドされています。プロパティは、次のようなカスタムタイプの無数のプロパティです。
public IEnumerable<Person> Persons
{
get { return _persons; }
set { _persons = value; }
}
フロードキュメントは、FlowDocumentScrollViewerコントロールに表示されます。ドキュメントは次のようになります。
code name lastname
---- ----- ---------
1 john johnson
1 peter peterson
2 jane jane
3 john doe
バインディングは正常に機能しますが、個別のコードごとに空白行を追加したいと思います。
code name lastname
---- ----- ---------
1 john johnson
1 peter peterson
2 jane jane
3 john doe
ビュー内の私のXamlは次のとおりです。
<FlowDocumentScrollViewer>
<FlowDocument>
<flowdoc:ItemsContent ItemsSource="{Binding Path=Persons}">
<flowdoc:ItemsContent.ItemsPanel>
<DataTemplate>
<flowdoc:Fragment>
<Table BorderThickness="1" BorderBrush="Black">
<TableRowGroup flowdoc:Attached.IsItemsHost="True">
<TableRow Background="LightBlue">
<TableCell>
<Paragraph>ronde</Paragraph>
</TableCell>
<TableCell>
<Paragraph>hal</Paragraph>
</TableCell>
<TableCell>
<Paragraph>datum</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</flowdoc:Fragment>
</DataTemplate>
</flowdoc:ItemsContent.ItemsPanel>
<flowdoc:ItemsContent.ItemTemplate>
<DataTemplate>
<flowdoc:Fragment>
<TableRow>
<TableCell>
<Paragraph>
<flowdoc:BindableRun BoundText="{Binding Path=Code}" />
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<flowdoc:BindableRun BoundText="{Binding Path=Name}" />
</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<flowdoc:BindableRun BoundText="{Binding Path=LastName}" />
</Paragraph>
</TableCell>
</TableRow>
</flowdoc:Fragment>
</DataTemplate>
</flowdoc:ItemsContent.ItemTemplate>
</flowdoc:ItemsContent>
MVVMルールに違反せずにこれを行う方法に関する提案はありますか?フロードキュメントのデータバインディングには、柔軟性のないレイアウトという代償が伴うようです。
前もって感謝します