我绑定了这个:
{[ "http://www.google.com", "http://www.sausage.com" ]}
的类型为:Newtonsoft.Json.Linq.JArray
<HyperlinkButton
Style="{StaticResource Blah}"
Content="{Binding}"
NavigateUri="{Binding}"
TargetName="_blank"></HyperlinkButton>
如果我用字符串替换内容,它显示正常。所以这表明它不是造型问题?
上下文
<u:ContactTemplate Content="{Binding TheContact.url}" HorizontalAlignment="Left" HorizontalContentAlignment="Left">
<u:ContactTemplate.PropertyListString>
<DataTemplate>
<ListBox x:Name="ContactTitle"
Background="Transparent"
ItemsSource="{Binding}"
VerticalContentAlignment="Top"
BorderThickness="5"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<HyperlinkButton
Style="{StaticResource SausageContactWebsiteLink}"
Content="{Binding}"
NavigateUri="{Binding}"
TargetName="_blank"></HyperlinkButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</u:ContactTemplate.PropertyListString>
</u:ContactTemplate>
如果我用正常的TextBlock替换HyperLinkButton:
<TextBlock
Style="{StaticResource SausageContactTextBlockStyle}"
Text="{Binding}"></TextBlock>
一切正常!
我的HyperLinkButton出了什么问题?
备注:
答案 0 :(得分:1)
如果你尝试过,它有效吗?
<TextBlock
x:Name="tb"
Visibility="Collapsed"
Text="{Binding}"></TextBlock>
<HyperlinkButton
Content="{Binding ElementName=tb,Path=Text}"
NavigateUri="{Binding ElementName=tb,Path=Text}"
TargetName="_blank"></HyperlinkButton>