NoWar
NoWar

Reputation: 37632

How to adjust TextBlock MultiBinding to TextBlock & Hyperlink?

I really couldn't find how to resolve the following problem. I have got:

<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>

And it works fine.

I want to use <Hyperlink> within <TextBlock>...

How I can adjust <MultiBinding> to do the same thing for <Hyperlink> instead of <TextBlock>?

Is it possible?

Upvotes: 2

Views: 1086

Answers (2)

brunnerh
brunnerh

Reputation: 185225

Hyperlinks can contain Runs, so you might want to apply the binding to the Text of a Run within the Hyperlink

Upvotes: 2

Tamir
Tamir

Reputation: 2533

Hyperlink is span and contains of inlines, thus

<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>

will work.

Upvotes: -1

Related Questions