Articles in categories

Now on Amazon

Stieven's Corner

Make WPF TextBox look like TextBlock

I needed a selectable TextBlock to show some id. However a TextBlock is not selectable so I made a TextBox look like a TextBlock. A TextBlock is selectable..

You only need the properties 'Background' and 'Border':

<TextBox x:Name="textBlockProductId"
	 Background="Transparent"
	 BorderThickness="0"
	 Text="{Binding SelectedProductId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

That's it, your TextBox will look like a TextBlock!