0
以下是我目前必须在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>
的想法是创造一些文本和具有它强调使得下划线伸展封闭容器的整个宽度,在这种情况下,网格布局。
更新:
我没有使用表,这是我能找到的工作,并没有把文字与线之间的巨大空间的唯一方法。我现在已经找到了看起来更简单的方法。
<BlockUIContainer>
<TextBlock Style="{StaticResource Text_LoginHeaderStyle}" Text="Skill Groups"/>
</BlockUIContainer>
<BlockUIContainer>
<Line Style="{StaticResource Control_TitleLineSeparator}" />
</BlockUIContainer>
但即使这似乎非常复杂。我已经修改了上面的文字以便自成体系。
你能发布这类自成一个例子吗?上面的代码缺少一些资源。另外,你是否必须使用表格? – 2009-07-28 21:29:28