WPF 在一个Button中添加多个Run实现x平方显示

首先添加上角标

Button button = new Button();
Run left=new Run("x");
Run right = new Run("2");
right.BaselineAlignment=BaselineAlignment.Superscript;

TextBlock textBlock = new TextBlock();
textBlock.Inlines.Add(left);
textBlock.Inlines.Add(right);

button.Content = textBlock;

结果

猜你喜欢

转载自blog.csdn.net/weixin_43891802/article/details/126341854