daniyalahmad
daniyalahmad

Reputation: 3863

Text underline by using ApplyPropertyValue

I want to underline the selected text by using textrange in ApplyProperyValue. Here is my single line of code :

new TextRange(start, end).ApplyPropertyValue(??, TextDecorations.Underline);

Upvotes: 1

Views: 948

Answers (2)

Bob.
Bob.

Reputation: 4002

According to the TextRange.ApplyPropertyValue Method MSDN file, the TextRange.ApplyPropertyValue Method method takes a DependencyProperty and an Object.

public void ApplyPropertyValue(
    DependencyProperty formattingProperty,
    Object value
)

You are probably looking for the Inline.TextDecorationsPropertyProperty Dependency Property.

new TextRange(start, end).ApplyPropertyValue(
    Inline.TextDecorationsProperty,
    TextDecorations.Underline);

Upvotes: 0

Rohit Vats
Rohit Vats

Reputation: 81313

You need to pass dependency property in there which is Inline.TextDecorationsProperty -

new TextRange(start, end).ApplyPropertyValue(Inline.TextDecorationsProperty,
                                                TextDecorations.Underline);

Upvotes: 2

Related Questions