|
<Window x:Class="ListBoxHyperlinkDemo.View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:ListBoxHyperlinkDemo.ViewModel"
Title="ListBox Hyperlink Demo" Height="300" Width="500" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Demo List Box" HorizontalAlignment="Center" FontSize="18" />
<ListBox Grid.Row="1" Margin="10,0,10,10" ItemsSource="{Binding Alerts}">
<ListBox.Resources>
<vm:PaddedStringConverter x:Key="StringConverter" />
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=AlertText, Converter={StaticResource StringConverter}}">
<Hyperlink Command="{Binding Path=LinkCommand, Converter={StaticResource CommandConverter}}">
<TextBlock Text="{Binding Path=LinkText}"/>
</Hyperlink>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.