DevPinoy.org
A Filipino Developers Community
   
How To: Create a BulletList in Silverlight

I was working on a prototype application today when I needed to use a BulletList. At first I thought it existed on the toolkit controls but to my surprise it wasn't so I ended up creating an ItemsControl template that mimics how a BulletList would behave. I wanted to post it here to show you how I did it

<UserControl x:Class="KeithRull.SLBulletList.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded">
        <ItemsControl x:Name="contestantsItemsControl">
            <ItemsControl.ItemTemplate>
                <DataTemplate>                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="30"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock
                                        Grid.Column="0"
                                        Margin="5 5 0 0"
                                        HorizontalAlignment="Left"
                                        Text="•"/>
                        <TextBlock
                                        Grid.Column="1"
                                        Margin="5"
                                        VerticalAlignment="Top"
                                        IsHitTestVisible="False"
                                        TextWrapping="Wrap"
                                        Text="{Binding}"/>
                    </Grid>                </DataTemplate>
            </ItemsControl.ItemTemplate>        </ItemsControl>
    </Grid>
</UserControl>

As allways you can download a sample project here: KeithRull.SLBulletList Fun! Now time to get back to my code zen. Cheers!


Posted 01-30-2011 1:44 AM by keithrull
Filed under:
Copyright DevPinoy 2005-2008