Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a bullet point in front of a text binding in wpf?

I have the following abbreviated for simplicity

<ItemsControl ItemSource="{Binding enumerableList}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBox Text="{Binding displayName, Mode=OneWay}" />
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

How can I get it so that my TextBox shows a bullet point in front of the text bound to it? Desired format:

  • List item 1
  • List item 2
like image 438
Lunyx Avatar asked Oct 08 '14 13:10

Lunyx


People also ask

What is databinding in WPF?

Data binding in Windows Presentation Foundation (WPF) provides a simple and consistent way for apps to present and interact with data. Elements can be bound to data from different kinds of data sources in the form of . NET objects and XML.

How to bind a property in XAML?

One-Way Data Binding The following XAML code creates four text blocks with some properties. Text properties of two text blocks are set to “Name” and “Title” statically, while the other two text blocks Text properties are bound to “Name” and “Title” which are class variables of Employee class which is shown below.

What is label in WPF?

Advertisements. The Label class provides both functional and visual support for access keys (also known as mnemonics). It is frequently used to enable quick keyboard access to controls.

How do I bind a text box in WPF?

One-Way Data Binding First of all, create a new WPF project with the name WPFDataBinding. The following XAML code creates two labels, two textboxes, and one button and initializes them with some properties.


1 Answers

You can use the BulletDecorator with the TextBlock. Example:

    <BulletDecorator>
      <BulletDecorator.Bullet>
        <Ellipse Height="10" Width="10" Fill="Blue"/>
      </BulletDecorator.Bullet>
        <TextBox Text="{Binding displayName, Mode=OneWay}" />
    </BulletDecorator>
like image 102
Sajeetharan Avatar answered Oct 19 '22 21:10

Sajeetharan