在 WPF 中,您可以使用对象轻松创建这种外观Path
来绘制边(这些边是直的)并UniformGrid
显示内容:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="300">
<Window.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Path Grid.Column="0" Data="M 0,0 0,300 15,300 15,295 5,295 5,5 15,5 15,0"
Width="15" Height="300" Fill="Black" VerticalAlignment="Stretch"
HorizontalAlignment="Center" />
<UniformGrid Grid.Column="1" Columns="2" Rows="2" TextElement.FontFamily=
"Palatino Linotype" TextElement.FontSize="28">
<TextBlock>
<Run Text="a" />
<Run Typography.Variants="Subscript" FontStyle="Italic" Text="11" />
</TextBlock>
<TextBlock>
<Run Text="a" />
<Run Typography.Variants="Subscript" FontStyle="Italic" Text="11" />
</TextBlock>
<TextBlock>
<Run Text="a" />
<Run Typography.Variants="Subscript" FontStyle="Italic" Text="21" />
</TextBlock>
<TextBlock>
<Run Text="a" />
<Run Typography.Variants="Subscript" FontStyle="Italic" Text="22" />
</TextBlock>
</UniformGrid>
<Path Grid.Column="2" Data="M 15,0 15,300 0,300 0,295 10,295 10,5 0,5 0,0"
Width="15" Height="300" Fill="Black" VerticalAlignment="Stretch"
HorizontalAlignment="Center" />
</Grid>
</Window>
要使其正常工作,需要注意两点重要的事情:
TextElement.FontFamily
您选择的必须能够显示Subscript
。
您可以绑定到Run.Text
属性,而不是像我在您的示例中那样硬编码值:
<Run Text="{Binding Value1}" />
<Run Typography.Variants="Subscript" FontStyle="Italic" Text="{Binding Value2}" />