wpfxamltextboxtextblock

Any way to make a WPF textblock selectable?


How to allow TextBlock's text to be selectable?

I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make it selectable?


Solution

  • Use a TextBox with these settings instead to make it read only and to look like a TextBlock control.

    <TextBox Background="Transparent"
             BorderThickness="0"
             Text="{Binding Text, Mode=OneWay}"
             IsReadOnly="True"
             TextWrapping="Wrap" />