Click here to Skip to main content
12,069,857 members (49,273 online)
Rate this:
 
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 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 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 9 Sep 2010
Copyright © CodeProject, 1999-2016
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