David Michaeli
David Michaeli

Reputation: 367

Bulleted list in RichTextBox - wpf

I have a control of RichTextBox in my xaml. On runtime i loaded a text from a rtf file. I noticed that if have a bulleted list it looks bad, for example, in rtf have:

• Text

• Text2

• Text3

• Text4

But after loaded into a RichTextBox control - it design as follow:

•Text

•Text2

•Text3

•Text4

So, I see that it append as follow - for every • it append a Span control, and set a property FontFamily to Symbol, and append new Run object and setting it to •,So my question - how to can i append a new child before for append spaces? it possible to append new child by using style? someting like:

<Style TargetType="{x:Type Span}">
                <Style.Triggers>
                    <Trigger Property="FontFamily" Value="Symbol">
                        ....
                    </Trigger>
                </Style.Triggers>
            </Style>

?

Upvotes: 2

Views: 3793

Answers (1)

CAD bloke
CAD bloke

Reputation: 8798

a kludge, perhaps but note the leading space in each Run. Using hyperlinks in a list I had to insert a Run with a single space in it.

<RichTextBox>
  <FlowDocument>
    <List MarkerStyle="Disc" MarkerOffset="1">
      <ListItem>
        <Paragraph>
          <Run Text=" Enough Angle brackets for you?"/>
        </Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>
          <Run Text=" Here, have some more"/>
        </Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>
          <Run Text=" "/>
          <Hyperlink NavigateUri="http://stackoverflow.com/" ToolTip="Why type when I can copy-paste?">
            <Run Text="Text inside the Hyperlink"/>
          </Hyperlink>
        </Paragraph>
      </ListItem>
    </List>
  </FlowDocument>
</RichTextBox>

Upvotes: 1

Related Questions