views:

338

answers:

2

Dear All,

I want to be able to read text from a Silverlight TextBlock (TextBlock Control) (Silverlight & C#) and check what formatting (as in: bold, italic, font size, etc...) has been applied to it, so I can store it in an XML file.

Is it possible to find out what formatting has been applied to a piece of text with C# and Silverlight so it can be stored and re-used later? The text would be contained within a textbox or textblock control.

Storage used can be XML but I've just found out Silverlight doesn't support XSL, so just XML.

Regards, T

A: 

By formatting you mean a phone number or date format?

If yes. Use regular expressions.

Take a look at the System.Text.RegularExpressions namespace. Everything there should help you.

Coincoin
A: 

Just make sure you give your control a name.

<Textblock x:Name="myTextBlock" />

In your code behind you can then access the TextBlock but calling it's name (myTextBlock).

Here you can add logic like:

if (myTextBlock.FontWeight == "Bold")
{
  //Do Something
}

From reading your needs you'll most likely be passing the object to a function and creating your xml file from there. Good luck.

mstrickland