Augusto Accorsi
Augusto Accorsi

Reputation: 327

How to add hyperlink to listbox item c#

I am doing a project where I add items in a listview, but items as websites, so is there a way that I could add a hyperlink in a listViewItem by my code?

Upvotes: 0

Views: 1344

Answers (1)

Dai
Dai

Reputation: 155443

I don't have much experience with XAML-for-Windows-Store, but I understand it's very similar to WPF: just define an <ItemTemplate> for the listview:

<ListView>
    <ListView.ItemTemplate>
        <DataTemplate>
            <HyperlinkButton Content="{Binding Path=DisplayText}" NavigateUri="{Binding Path=Href}" />
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

This code assumes the items you're adding to the ListView have two string properties: DisplayText and Href.

Upvotes: 1

Related Questions