在 WPF FlowDocument 的同一行上保留一个浮动元素
Keep a floated element on the same line in a WPF FlowDocument
我在谷歌上搜索了几个小时,虽然有很多关于如何浮动 WPF 元素的示例,但我很难获得两个浮动在同一行上的简单元素。这是我的代码
<FlowDocument ColumnWidth="999999">
<Section>
<Paragraph>
<Floater HorizontalAlignment="Left" Width="200">
<Paragraph>
<Run Text="Hello World Left"/>
</Paragraph>
</Floater>
<Floater HorizontalAlignment="Right" Width="200">
<Paragraph>
<Run Text="Hello World Right"/>
</Paragraph>
</Floater>
</Paragraph>
</Section>
</FlowDocument>
我希望它们出现在页面左侧和右侧的同一行上。然而,右侧的一个被向下移动了一条线:
如何使右侧的浮动元素与左侧的浮动元素保持相同的高度?
不知道它为什么有效(可能与悬挂或缩进有关),设置一个空的 运行 作为段落的第一个内联:
<Paragraph >
<Run />
<Floater HorizontalAlignment="Left" Background="AliceBlue"
BaselineAlignment="TextBottom" Width="200">
<Paragraph>
<Run Text="Hello World Left"/>
</Paragraph>
</Floater>
<Floater HorizontalAlignment="Right" Background="AntiqueWhite"
BaselineAlignment="TextBottom" Width="200">
<Paragraph>
<Run Text="Hello World Right"/>
</Paragraph>
</Floater>
</Paragraph>
我在谷歌上搜索了几个小时,虽然有很多关于如何浮动 WPF 元素的示例,但我很难获得两个浮动在同一行上的简单元素。这是我的代码
<FlowDocument ColumnWidth="999999">
<Section>
<Paragraph>
<Floater HorizontalAlignment="Left" Width="200">
<Paragraph>
<Run Text="Hello World Left"/>
</Paragraph>
</Floater>
<Floater HorizontalAlignment="Right" Width="200">
<Paragraph>
<Run Text="Hello World Right"/>
</Paragraph>
</Floater>
</Paragraph>
</Section>
</FlowDocument>
我希望它们出现在页面左侧和右侧的同一行上。然而,右侧的一个被向下移动了一条线:
如何使右侧的浮动元素与左侧的浮动元素保持相同的高度?
不知道它为什么有效(可能与悬挂或缩进有关),设置一个空的 运行 作为段落的第一个内联:
<Paragraph >
<Run />
<Floater HorizontalAlignment="Left" Background="AliceBlue"
BaselineAlignment="TextBottom" Width="200">
<Paragraph>
<Run Text="Hello World Left"/>
</Paragraph>
</Floater>
<Floater HorizontalAlignment="Right" Background="AntiqueWhite"
BaselineAlignment="TextBottom" Width="200">
<Paragraph>
<Run Text="Hello World Right"/>
</Paragraph>
</Floater>
</Paragraph>