Reputation: 1315
I currently have a listBox
in a WP7 application that uses databinding to populate it. The problem I'm having though is with this particular line:
<Hyperlink NavigateUri="{Binding LinkUrl}" TargetName="_blank">{Binding Name}</Hyperlink>
It seems that I can't bind things in this way (outside of an element's attributes). All this does is create a hyperlink with the literal text {Binding Name} linked to the url. Instead what I'm looking for is for it to use the actual Name variable in its place.
I've tried googling for an answer and looked into the Inlines attribute, but I keep coming up empty handed.
Any help would be appreciated
Upvotes: 4
Views: 366
Reputation: 11608
In WPF, the space between the tags is usually the 'content' (but not always) and bindable via the Content
property. I'm unfamiliar with <Hyperlink>
in Windows Phone, but a <HyperlinkButton>
should work just as well.
<HyperlinkButton NavigateUri="{Binding LinkUrl}" TargetName="_blank" Content="{Binding Name}"/>
EDIT: For a <Hyperlink>
in a <RichTextBox>
try this:
<RichTextBox>
<Paragraph>
<Hyperlink>
<Hyperlink.Inlines>
<Run Text="{Binding Name}"/>
</Hyperlink.Inlines>
</Hyperlink>
</Paragraph>
</RichTextBox>
Upvotes: 4