Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Key
M11
M12
M21
M22
Tag
Uri
X1
X2
Y1
Y2
Expand Minimize

TextDecorations

Silverlight

Gets or sets the text decoration for the content in this element.

<object TextDecorations="TextDecorations"  .../>
value = object.TextDecorations
object.TextDecorations = value

Type: TextDecorations Enumeration

One of the enumeration values that specifies the desired text decoration.

This property is read/write. The default value is None.

By using the TextDecorations property, you can create the visual appearance of a hyperlink in a Run or TextBlock object.

The "Applies To" section of this topic lists LineBreak, because it does exist in the object model and you can get and set it. However, all LineBreak properties are ignored for rendering purposes.

The following XAML example shows how to define a TextBlock that simulates a hyperlink by displaying an underline in response to the MouseEnter event. The underline is removed in response to the MouseLeave event. Notice that the Cursor property is set to display the Hand cursor when the mouse pointer is over the TextBlock.

<TextBlock
  Text="Click to Win!"
  TextDecorations="None"
  Cursor="Hand"
  FontSize="14" FontWeight="Bold"
  MouseEnter="onMouseEnter"
  MouseLeave="onMouseLeave"
  MouseLeftButtonUp="onMouseLeftButtonUp" />

The following JavaScript example shows the corresponding event-handling functions for the TextBlock that is defined in the previous XAML example.

function onMouseEnter(sender, mouseEventArgs)
{
    sender.textDecorations = "Underline";
    sender.foreground="Maroon";
}

function onMouseLeave(sender, mouseEventArgs)
{
    sender.textDecorations = "None";
    sender.foreground="Black";
}

function onMouseLeftButtonUp(sender, mouseEventArgs)
{
    alert("Congratulations!");
}

Community Additions

ADD
Show:
© 2015 Microsoft