Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, maybe the title of my question is not so understandable, so, I will explain a little bit better, the task is to get when i touch in my keyboard the "shift" key an event indicating to my TextBox that I have to put an elevated number, just like the "Superindex" in Microsoft Word, to represent the power of a variable, I need a way to represent this in a text box in WPF. For example, I want to represent this polynomic expression in a TextBox --> X^2+3, but instead having this, I want to have the expression represented in the mathematical way, please, I require your help, thanks, and excuse me for the english, is not the best...
Posted
Comments
Kenneth Haugland 10-Feb-15 9:36am    
<textbox>E=MC<run baselinealignment="Superscript" fontsize="12pt">2
Kenneth Haugland 10-Feb-15 9:37am    
:Laugh: It mocked up my comment completely..

1 solution

The approach is outlined here:
http://stackoverflow.com/questions/1252114/superscript-subscript-in-hyperlink-in-wpf[^]
Something like:
XML
<textblock><run baselinealignment="Superscript" fontsize="12pt">TEST</run>
     E=MC<run baselinealignment="Superscript" fontsize="12pt">2</run>
   </textblock>
 
Share this answer
 
Comments
Cesar Bretana Gonzalez 10-Feb-15 9:47am    
Yeah, that's fine, but how can I handle that behaviour with my keyboard, and represent that in a text box, for example: x^2 --> x², I want that when I have the shift key pressed, thanks...
Kenneth Haugland 10-Feb-15 9:59am    
Handle it on Textbox KeyDownPreview I guess, and find out if if Keyboard.IsPressed(Key.ALt) or somehting. It would perhaps be better to make a Checkbox, and when its IsCHecked you send all the text to subscript etc.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900