2017-10-19 135 views
0

我想要一个Button出现在Hyperlink上。正如你可以看到它现在是FlowDocument的一部分,并坐在超链接旁边!但我希望它具有绝对位置,以便它可以出现在超链接上!我怎样才能做到这一点?在WPF中的FlowDocument中的UIElement的绝对定位

<FlowDocumentScrollViewer> 
    <FlowDocument> 
     <Paragraph> 
      The maximum speed is 
      <Hyperlink>150</Hyperlink> 
      <InlineUIContainer> 
       <Button>No way!</Button> 
      </InlineUIContainer> 
      in this road! 
     </Paragraph> 
    </FlowDocument> 
</FlowDocumentScrollViewer> 

回答

1

可以使用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> 
+0

谢谢,但我希望它是在hyperlink- – Vahid

+0

你的意思是你希望它是“上面”所以你看不到的超级链接?如果是这样,为什么你需要超链接? – DinoM

+0

我希望它在我超链接后出现!我已经使用Button来简化了!它将是Slider。超链接将是一个整数值,当我点击它时,滑块将出现!这是我的最终目标! – Vahid