[英]Absolute positioning of UIElement in FlowDocument in WPF
我希望在Hyperlink
上出現一個Button
。 如您所見,它現在是FlowDocument
一部分,位於超鏈接旁邊! 但我希望它具有絕對位置,以便它可以顯示在超鏈接上! 我怎樣才能做到這一點?
<FlowDocumentScrollViewer>
<FlowDocument>
<Paragraph>
The maximum speed is
<Hyperlink>150</Hyperlink>
<InlineUIContainer>
<Button>No way!</Button>
</InlineUIContainer>
in this road!
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
您可以使用StackPanel
來“堆疊”從UIElement
繼承的多個對象。 Hyperlink
不是從UIElement
繼承的,但是您可以通過將超Hyperlink
放置在ContentControl
來解決此問題。
這是一個工作示例:
<FlowDocumentScrollViewer>
<FlowDocument>
<Paragraph>
The maximum speed is
<StackPanel>
<Button>No way!</Button>
<ContentControl HorizontalAlignment="Center">
<Hyperlink>150</Hyperlink>
</ContentControl>
</StackPanel>
in this road!
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
編輯的代碼,其中“ Button
出現在“ Hyperlink
頂部(z順序較高)(請參見注釋)。
<FlowDocumentScrollViewer>
<FlowDocument>
<Paragraph>
The maximum speed is
<Grid>
<Button>No way!</Button>
<ContentControl HorizontalAlignment="Center">
<Hyperlink>150</Hyperlink>
</ContentControl>
</Grid>
in this road!
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.