How to write Maths Equation In Silverlight

Hello All,

Inspite of being a PG in Mathematics I always use to think how should we write a maths equation in Silverlight or say superscript for a texblock, So I thought I should blog for it.

Suppose if we want to write an equation something like this:

then how are we going to write this in Silverlight.
Here is a simple way:

I have take a TextBlock in my Xaml Page named tbMathsEquation.
In Code Behind: 
tbMathsEquation.Text  = "(x + 1)";
tbMathsEquation.Text += String.Format(" {0,-3}", '\u00B2');
tbMathsEquation.Text += " = ";
tbMathsEquation.Text += "x";
tbMathsEquation.Text += String.Format(" {0,-3}", '\u00B2');
tbMathsEquation.Text += " + ";
tbMathsEquation.Text += "2x + 1";
 
Here I'm using Unicode Character which might be categorized as an uppercase letter, a lowercase letter, a decimal digit number, a letter number, a connector punctuation, a math symbol, or a currency symbol.
 
Thats all we have to do.
 
Happy Coding :)

No comments:

Post a Comment