WPF Display Math number square, show big character and small character via Textblock run horizontal without space BaselineAlignment="Baseline" BaselineAlignment="Subscript"
//xaml <Window x:Class="WpfApp37.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp37" mc:Ignorable="d" WindowState="Maximized" Title="MainWindow" Height="450" Width="800"> <Window.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontSize" Value="50"/> </Style> </Window.Resources> <Grid x:Name="gd"> <Grid.RowDefinitions> <RowDefinition Height="200"/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="Quadratic formula: x = (−b ± √(b² − 4ac)) / (2a)" VerticalAlignment="Center"/> <TextBlock Grid.Row="1" Text="R²"/> <TextBlock Grid.Row="2"> <Run Text="K" FontSize="24" BaselineAlignment="Baseline" /><Run Text="D" FontSize="12" BaselineAlignment="Subscript"/> </TextBlock> <TextBlock Grid.Row="4"> <TextBlock.Inlines> <Run Text="K" FontSize="24" FontWeight = "Bold" BaselineAlignment="Baseline"/><Run Text="D" FontSize="12" FontWeight = "Bold" BaselineAlignment="Subscript"/> </TextBlock.Inlines> </TextBlock> </Grid> </Window> //cs using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApp37 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var textBlock = new TextBlock(); textBlock.Inlines.Add(new Run("K") { FontSize = 24, FontWeight = FontWeights.Bold }); textBlock.Inlines.Add(new Run("D") { FontSize = 12, FontWeight = FontWeights.Bold, BaselineAlignment = BaselineAlignment.Baseline, }); Grid.SetRow(textBlock, 3); gd.Children.Add(textBlock); } } }