WPF で下線付きのヘッダー テキストを作成するために現在必要なコードを次に示します。テーブルを使用するよりも簡単な方法が必要です。
<Grid>
<FlowDocumentScrollViewer>
<FlowDocument>
<Table>
<Table.Columns>
<TableColumn Width="Auto"/>
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>
<Paragraph Style="{StaticResource Text_LoginHeaderStyle}">
<Bold>Some header text</Bold>
</Paragraph>
</TableCell >
</TableRow>
<TableRow>
<TableCell>
<BlockUIContainer>
<Line Style="{StaticResource Control_TitleLineSeparator}" />
</BlockUIContainer>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer>
</Grid>
ラインの定義は
<Style x:Key="Control_TitleLineSeparator" TargetType="Line" BasedOn="{StaticResource BasicHorizontalLine}">
<Setter Property="Stroke" Value="Gray"/>
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="Margin" Value="0,0,0,3"/>
</Style>
アイデアは、いくつかのテキストを作成し、下線が囲んでいるコンテナー (この場合は Grid レイアウト) の幅全体に広がるように下線を引くことです。
アップデート:
表を使用する必要はありません。それが機能することがわかった唯一の方法であり、テキストと行の間に大きなスペースを入れませんでした。私は今、より単純な方法と思われるものを見つけました。
<BlockUIContainer>
<TextBlock Style="{StaticResource Text_LoginHeaderStyle}" Text="Skill Groups"/>
</BlockUIContainer>
<BlockUIContainer>
<Line Style="{StaticResource Control_TitleLineSeparator}" />
</BlockUIContainer>
しかし、これでさえ信じられないほど複雑に思えます。上記のテキストを自己完結型に変更しました。