WPF TextBlock下划线
我有一个width 500的textblock ,但我的string只是说“H”,但我想underline整个textblock宽度不只是在H下我该怎么办? 
您应该使用TextBlock的属性“TextDecorations”。 像那样:
  <TextBlock Text="H" TextDecorations="Underline"/> 
只需要添加我的2美分,就可以在运行时通过这个代码实现与Talia的答案相同的效果:
 YourTextBlock.TextDecorations = System.Windows.TextDecorations.Underline; 
出于某种原因,VS2010并没有显示RHS的Intellisense,但它编译和运行正确。
  <TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="40" Height="40" FontSize="16" Tapped="TextBlock_Tapped" Text="Text" Foreground="{StaticResource LightBlue}"> <Underline> <Run Text="Text"/> </Underline> </TextBlock> 
你最好的select可能是在文本块的正下方使用矩形,其宽度始终是文本块的宽度。 喜欢这个:
 <DockPanel LastChildFill="False"> <TextBlock DockPanel.Dock="Top" x:Name="blockToUnderline" Text="H" Width="76" /> <Rectangle DockPanel.Dock="Top" Fill="Black" Height=1 Width="{Binding ElementName=blockToUnderline, Path=ActualWidth}" /> </DockPanel>