How to add a border to the Text inside a TextBlock in WPF?

munna picture munna · Feb 24, 2011 · Viewed 17.9k times · Source

I am kinda new to WPF, dont know if the question is weird. I wanted to know if its possible to add a border around the text inside a textBlock.

EDIT:

As per suggestion I have tried both but without much success:

<Border BorderBrush="#FF0B232F" BorderThickness="2">
   <TextBlock HorizontalAlignment="Left" Text="TextBlock" TextWrapping="Wrap" FontSize="36" FontWeight="Bold" Foreground="#FF88BCCD" OpacityMask="Black"/>      
</Border>

and

<Label BorderBrush="#FF0B232F" BorderThickness="2,2,2,2" Content="TextBlock" FontSize="36" FontWeight="Bold" Foreground="#FF88BCCD" />

Am I doing something wrong here?

Answer

Y.Yanavichus picture Y.Yanavichus · Feb 24, 2011

In such cases I use Label or TextBlock placed in Border.