0

Can I make a bold effect on specified text in a RichTextBlock?

Example RichTextBlock content:

It allows you to make some unknown jobs quickly

I should make a bold effect on the word "unknown" so it should look like:

It allows you to make some unknown jobs quickly

I can add linebreak with UNICODE characters. It is "\u2028". Is there any code to make bold effect with UNICODE?

2 Answers2

1

According to the source below, you can insert <Bold> tags to format your text.

Try the following in your XAML document and see if it works:

It allows you to make some <Bold>unknown</Bold> jobs quickly

Source: http://msdn.microsoft.com/en-us/library/aa970779.aspx

  • I added a Paragraph and Run element in richTextBlock. When I change text of Run element to your tags, it doesn't effect. Output was like it : It allows you to make some unknown jobs quickly – user2599950 Jul 22 '13 at 18:28
0

Yes, you can add text effects for any range of characters that you want. Here is a code snippet in VB.net - sorry I don't do c#.

One way is to change the current font before you append new text:

rtbEmail.SelectionFont = New Font(rtbEmail.Font.Name, CSng(rtbEmail.Font.Size * 1.25))
rtbEmail.AppendText("To: " & emailparts.ToData & vbCrLf & "From: " & emailparts.FromData & vbCrLf & "Subject: " & emailparts.SubjectData & vbCrLf)

Another way is to define a beginning and end of a range of text:

highlightstart = rtbEmail.TextLength
rtbEmail.AppendText(msg.Message)
rtbEmail.SelectionStart = highlightstart
rtbEmail.SelectionLength = rtbEmail.TextLength - highlightstart
rtbEmail.SelectionFont = New Font("Courier New", rtbEmail.Font.Size, FontStyle.Regular)

HTH - Ken

Ken
  • 1
  • 2
  • This may not be useful because the examples aren't in the example language that the OP is using. – Patrick Sebastien Jul 22 '13 at 18:11
  • richTextBlock element doesn't contain a method like "SelectionFont" or "AppendText". It is not "RichTextBox". So it won't be helpful. – user2599950 Jul 22 '13 at 18:29
  • @Patrick - Yes, I know, but certainly the OP can do the translation. #user2599950 - Yeah, I guess I read it wrong. My bad. – Ken Sep 29 '14 at 14:23