Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Label Text Underline?

Tags:

How can I make Label text Underline in WPF? I am stucked and could not find any property for underline:

<Label Name="lblUserName"        Content="Username"        FontSize="14" FontWeight="Medium" /> 
like image 704
Hassaan Avatar asked Mar 24 '14 12:03

Hassaan


People also ask

How do you underline text in a HTML label?

To underline a text in HTML, use the <u> tag. The <u> tag deprecated in HTML, but then re-introduced in HTML5. Now it represents a text different from another text stylistically, such as a misspelled word. To underline a text, you can also use the style attribute.

How do I underline a label in Xcode?

Select the text of the label, right click and change the font to 'underline'.

How do you underline text in WPF?

To add a text decoration to text, create a TextDecoration object and modify its properties. Use the Location property to specify where the text decoration appears, such as underline. Use the Pen property to specify the appearance of the text decoration, such as a solid fill or gradient color.

How do you underline in TKinter?

Build A Paint Program With TKinter and Python Sometimes, we need to style the font property of Label Text such as fontfamily, font-style (Bold, strike, underline, etc.), font-size, and many more. If we want to make the label text underlined, then we can use the underline property in the font attribute.


1 Answers

In Label no TextDecorations, therefore try this:

<Label Width="100" Height="30">     <TextBlock TextDecorations="Underline">TestText</TextBlock> </Label> 

Edit: more universal solution

In this case, instead of Label.Content using Label.Tag, because Content property can be set only once:

<Label Tag="TestContent"         Width="100"         Height="30"        HorizontalContentAlignment="Center"        Background="AliceBlue">      <TextBlock TextDecorations="Underline"                 Text="{Binding Path=Tag,                                RelativeSource={RelativeSource Mode=FindAncestor,                                                              AncestorType={x:Type Label}}}" /> </Label> 
like image 190
Anatoliy Nikolaev Avatar answered Sep 22 '22 06:09

Anatoliy Nikolaev