Search code examples
wpfitemscontrol

WPF Databound Bulleted List


How do I create a databound, bulleted list of hyperlinks in WPF?

I've got this:

<ItemsControl Name="lstScripts">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBlock>
                <Hyperlink>
                    <TextBlock Text="{Binding Path=Name}" />
                </Hyperlink>
            </TextBlock>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

But I can't figure out how to turn the items into bullets. I see the BulletDecorator, but I don't want to specify my own bullet image, I just want standard bullets.


Solution

  • Unfortunately there are no "standard bullets"... Here's an example of a simple Ellipse bullet :

            <ItemsControl Name="lstScripts">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <BulletDecorator Width="Auto">
                            <BulletDecorator.Bullet>
                                <Ellipse Fill="White" Stroke="Black" StrokeThickness="1" Width="8" Height="8"/>
                            </BulletDecorator.Bullet>
                            <TextBlock>
                                <Hyperlink>
                                    <TextBlock Text="{Binding Path=Name}" />
                                </Hyperlink>
                            </TextBlock>
                        </BulletDecorator>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>