c# – 如何在wpf文本绑定前添加一个项目符号?

前端之家收集整理的这篇文章主要介绍了c# – 如何在wpf文本绑定前添加一个项目符号?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
为简单起见,我有以下缩写
  1. <ItemsControl ItemSource="{Binding enumerableList}">
  2. <ItemsControl.ItemTemplate>
  3. <DataTemplate>
  4. <TextBox Text="{Binding displayName,Mode=OneWay}" />
  5. </DataTemplate>
  6. </ItemsControl.ItemTemplate>
  7. </ItemsControl>

我如何得到它,以便我的TextBox在文本前面显示一个项目符号呢?所需格式:

>列表项目1
>列表项目2

解决方法

您可以将 BulletDecorator与TextBlock一起使用.例:
  1. <BulletDecorator>
  2. <BulletDecorator.Bullet>
  3. <Ellipse Height="10" Width="10" Fill="Blue"/>
  4. </BulletDecorator.Bullet>
  5. <TextBox Text="{Binding displayName,Mode=OneWay}" />
  6. </BulletDecorator>

猜你在找的C#相关文章