WPF数据绑定项目符号列表

WPF数据绑定项目符号列表,wpf,itemscontrol,Wpf,Itemscontrol,如何在WPF中创建超链接的数据绑定、项目符号列表 我有这个: <ItemsControl Name="lstScripts"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock> <Hyperlink> <TextBlock Text="{Binding

如何在WPF中创建超链接的数据绑定、项目符号列表

我有这个:

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


但我不知道如何把这些东西变成子弹。我看到BulletDecorator,但我不想指定我自己的项目符号图像,我只想要标准项目符号。

不幸的是,没有“标准项目符号”。。。下面是一个简单椭圆项目符号的示例:

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

为了稍微扩展@Thomas Levesque的答案,将其转换为用户控件,以便可以重用,例如:

<Reporting:BulletedItem BulletText="Bullet Item 1" />
<Reporting:BulletedItem BulletText="Bullet Item 2" />

对于所有类型的列表,您都可以使用FlowDocument和list。这有一个标记样式“Disc”和一个标记样式“Circle”


硼
碳素

在某种程度上有标准的子弹。您可以使用TextBlock作为项目符号来显示Unicode项目符号U+2022。
<UserControl x:Class="MyNameSpace.Reporting.BulletedItem"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" >
    <Grid>
        <ItemsControl >
            <BulletDecorator Width="Auto" Margin="10, 0, 0, 0">
                <BulletDecorator.Bullet>
                    <Ellipse Fill="Black" Stroke="Black" StrokeThickness="1" Width="5" Height="5"/>
                </BulletDecorator.Bullet>
                <TextBlock Margin="5, 0, 0, 0">
                    <TextBlock Text="{Binding BulletText}" />
                </TextBlock>
            </BulletDecorator>
        </ItemsControl>
    </Grid>
</UserControl>
public partial class BulletedItem : UserControl
{
    public static readonly DependencyProperty TextProperty = DependencyProperty.Register("BulletText", typeof(string), typeof(BulletedItem));

    public string BulletText
    {
        get { return (string)GetValue(TextProperty); }
        set { SetValue(TextProperty, value); }
    }

    public BulletedItem()
    {
        InitializeComponent();
        this.DataContext = this;
    }
}
<FlowDocument>
  <List MarkerStyle="Disc">
    <ListItem>
      <Paragraph>Boron</Paragraph>
    </ListItem>
    <ListItem>
      <Paragraph>Carbon</Paragraph>
    </ListItem>
</<FlowDocument>