在WPF流程文档中,将浮动元素保持在同一行上
我在谷歌上搜索了几个小时,虽然有很多关于如何浮动WPF元素的例子,但我很难得到两个浮动在同一行上的简单元素。这是我的密码在WPF流程文档中,将浮动元素保持在同一行上,wpf,xaml,flowdocument,Wpf,Xaml,Flowdocument,我在谷歌上搜索了几个小时,虽然有很多关于如何浮动WPF元素的例子,但我很难得到两个浮动在同一行上的简单元素。这是我的密码 <FlowDocument ColumnWidth="999999"> <Section> <Paragraph> <Floater HorizontalAlignment="Left" Width="200"> &l
<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>
我认为使用浮动框可以忽略宽度,并且他们采用列的宽度。查看MSDN上的Floater
部分。仔细阅读示例后,宽度似乎被指定为一个双精度,表示其宽度与其父级宽度的比率。因此0.5
将是列宽的一半。MSDN上对示例的评论似乎与文档中所说的不一致,因此我不确定它实际上是如何工作的。我建议测试0.33
之类的值,看看它是否有任何效果。