简体   繁体   中英

XAML HyperLinkButton not showing content

I am binding this:

{[ "http://www.google.com", "http://www.sausage.com" ]}

which is of type: Newtonsoft.Json.Linq.JArray

<HyperlinkButton 
    Style="{StaticResource Blah}" 
    Content="{Binding}"
    NavigateUri="{Binding}"
    TargetName="_blank"></HyperlinkButton>

If I replace Content with a string, it shows fine. so this suggests it's not a styling issue?

Context:

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

If I replace the HyperLinkButton with a normal TextBlock:

<TextBlock 
    Style="{StaticResource SausageContactTextBlockStyle}"
    Text="{Binding}"></TextBlock>

It works fine!

What's wrong with my HyperLinkButton?

Notes:

  • If I place " http://www.google.com " directly into the Content and NavigateURI property it works too, so it's not some weird problem with urls.

sorry, I can not comment.

If you tried that , is it working ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM