Skip to main content
Home Forums Silverlight Programming Visual Studio & Silverlight Development Tools Add formating of Textbox to Textblock
1 replies. Latest Post by jeetAbhi on July 7, 2008.
(0)
okaravian
Member
113 points
81 Posts
07-07-2008 6:27 AM |
I want to Copy the text and its formating(Bold, Italic, Underline, Color etc) from textbox control to Textblock control.
How can I do this, anybody help me out.
example:
//this is code on click of the textblok, I want to add the text and formating contained in richTextBox in "textblock".
private void userNameLabel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.textblock.Text = richTextBox.Text.ToString();//This is for copying of text only but I want to apply th same formating as it has in richtextbox.
?????????????????????????????????????? }
thanks in advance.....
Mark as answered If this content leads to the correct wayregardsNasim Ul Haq
jeetAbhi
424 points
07-07-2008 7:02 AM |
If you are not adding textblock runtime then you can apply same properties (Bold, Italic, Underline, Color etc) to the textblock inside page.xaml....
And then just inside codebehind pass on the text as you have done above.
Or you can go this way too.........
PAGE.XAML
PAGE.XAML.CS
{
copyBlock.FontStyle = richTextBox.FontStyle;
copyBlock.FontWeight = richTextBox.FontWeight;
copyBlock.Foreground = richTextBox.Foreground;
copyBlock.Text = richTextBox.Text;
}
and you are done....this works for me SL 2 beta 2 and blend 2.5 june preview...
Kindly MARK AS ANSWER if this helps.........