If you are using XAML / WPF, you should use TextBlock instead of TextBox .
ONLY IF YOU USE THE TEXT AS A DISPLAY AND NOT FOR ENTRANCE - since TextBlock pretends that the text is "engraved" on the form itself, and not inside the text field. To get the border around the TextBlock (if you want), you can do this:
In XAML, for example:
<Border BorderThickness="1" BorderBrush="Gray"> <TextBlock Background="White" Text="Your Own TextBlock"/> </Border>
Or dynamically in C # Code:
//Create a Border object Border border = new Border(); border.BorderThickness = new Thickness(1); border.BorderBrush = Brushes.Black; //Create the TextBlock object TextBlock tb = new TextBlock(); tb.Background = Brushes.White; tb.Text = "Your Own TextBlock"; //Make the text block a child to the border border.Child = tb;
source share