如何将TextBlock MultiBinding调整为TextBlock&超链接?

时间:2012-01-25 16:52:08

标签: .net wpf xaml

我真的找不到如何解决以下问题。我有:

<TextBlock  Style="{StaticResource HoverBox}"   HorizontalAlignment="Left" Margin="0,0,5,0" Name="lblAuthFullPath"  VerticalAlignment="Top" Width="575"                                                     TextWrapping="Wrap" Padding="5,0,0,0" 
MouseLeftButtonDown="lblAuthFullPath_MouseLeftButtonDown">
     <TextBlock.Text>
           <MultiBinding  StringFormat="{}{0}{1}{2}">
                  <Binding Path="Text" ElementName="tbxAuthHost" />
                  <Binding Path="Text" ElementName="tbxAuthWebsiteName" />
                  <Binding Path="Text" ElementName="tbxWebServicesAuthentication" />
             </MultiBinding>
     </TextBlock.Text>
</TextBlock>

它运作正常。

我想在<Hyperlink> ...

中使用<TextBlock>

我如何调整<MultiBinding><Hyperlink> 而不是 <TextBlock>做同样的事情?

有可能吗?

2 个答案:

答案 0 :(得分:2)

Hyperlinks可以包含Runs,因此您可能希望将绑定应用于Text

Run的{​​{1}}

答案 1 :(得分:-1)

超链接是跨度并包含内联,因此

<Hyperlink>
<TextBlock  Style="{StaticResource HoverBox}"   HorizontalAlignment="Left" Margin="0,0,5,0" Name="lblAuthFullPath"  VerticalAlignment="Top" Width="575"                                                     TextWrapping="Wrap" Padding="5,0,0,0" 
MouseLeftButtonDown="lblAuthFullPath_MouseLeftButtonDown">
     <TextBlock.Text>
           <MultiBinding  StringFormat="{}{0}{1}{2}">
                  <Binding Path="Text" ElementName="tbxAuthHost" />
                  <Binding Path="Text" ElementName="tbxAuthWebsiteName" />
                  <Binding Path="Text" ElementName="tbxWebServicesAuthentication" />
             </MultiBinding>
     </TextBlock.Text>
</TextBlock>
</Hyperlink>

会奏效。