我应该如何创建具有自己的可视化表示的自定义flowdocument控件?

时间:2014-02-19 18:34:31

标签: wpf flowdocument

如何创建一个允许我不断重复某些FlowDocument元素的控件。

我希望能够拥有如下所示的Xaml:

<MyCustomControl>
    <Paragraph>Paragraph 1</Paragraph>
</MyCustomControl>

但让它渲染就好像它是这样的:

<Section>
    <Paragraph>This is Header Text</Paragraph>
    <Section> <!-- this is user area -->
        <Paragraph>Paragraph 1</Paragraph>
    </Section>
    <Paragraph>This is Footer Text</Paragraph>
</Section>

我尝试从Section下降,并将此奖励内容放在属性

(前面的恶劣代码)

<MyCustomControl StuffOnInside="&ltParagraph&gtParagraph 1&lt/Paragraph&gt" />

但是当它被序列化时,它将StuffOnInside序列化了两次,创建了重复的数据,当涉及到其他事情时又一团糟

<MyCustomControl StuffOnInside="&ltParagraph&gtParagraph 1&lt/Paragraph&gt">
    <Paragraph>This is Header Text</Paragraph>
    <Section> <!-- this is user area -->
        <Paragraph>Paragraph 1</Paragraph>
    </Section>
    <Paragraph>This is Footer Text</Paragraph>
</MyCustomControl>

0 个答案:

没有答案
相关问题