Daniel Peñalba
Daniel Peñalba

Reputation: 31887

How to set TextFormattingMode programmatically?

How can I set the TextFormattingMode property programmatically to the MainWindow class?

<Window x:Class="EditorExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"            
        TextOptions.TextFormattingMode="Display">
</Window>

Upvotes: 1

Views: 438

Answers (2)

Hamlet Hakobyan
Hamlet Hakobyan

Reputation: 33381

I assume that you want to set from ManiWindow class. TextOptions.TextFormattingMode is an attached property.

this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);

Upvotes: 5

Ayyappan Subramanian
Ayyappan Subramanian

Reputation: 5366

You add the property using the below code.

TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);

Upvotes: 2

Related Questions