Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Silverlight
Hi Guys,
 
How to make a static string Bold...
 
My Task..........
 
TextBlock textblock = new TextBlock();
textblock.Text = "Display Metrics:";
textblock.FontWeight = FontWeights.Bold;
String str=textblock.Text;
mystackpanel.Children.Add(textblock);
 
Now textblock has a "Display Metrics" text which is bold, how to copy this bold text to a String str.
Posted 29-Jan-10 4:09am
Edited 9-Sep-10 2:57am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The String class in .NET holds a sequence of Unicode characters. It does not hold any formatting information.
 
Nick
  Permalink  
Comments
KunalChowdhury at 9-Sep-10 8:01am
   
Posted by amjad syed on 30 Jan '10:
 
Hi Nick, Thanks for your answer. so any other alternate for this.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You could save the values in an XML format. You could save Text to an element and you could save FontWeight to an attribute. Get them both from textblock.
 
Also, since TextBlocks can contain text with a variety of formatting, you might want to look into TextBlock.Inlines, which will help get the formatting of TextBlocks created like so:
<TextBlock Name="tb1">
    This has some <Bold>bold</Bold> text.
</TextBlock>
  Permalink  
Comments
KunalChowdhury at 9-Sep-10 8:04am
   
Posted by amjad syed on 1 Feb '10:
 
I am not allowed to use textblock...... i can use richtextbox, but as per my knowledge there is control called Richtetxblock in Silverlight, if have any dll for this plsease forward me. please feel free to tell me the alternate solution.
aspdotnetdev at 9-Sep-10 22:24pm
   
I don't see any comments by amjad that say that.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You could try using a rich text box to display text.
 
This way you can copy the rich text format and then paste in another rich text box.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

RichTextBox here.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 9 Sep 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100