The element in XAML represents a TextBox control. The following code sets a TextBox control properties in XAML.
The following code snippet sets controls location by the Margin, VerticalAlignment and HorizontalAlignment properties.
  1. <TextBox Name="TextBox1" Height="30" Width="200"
  2. Text="Hello! I am a TextBox."
  3. Margin="10,10,0,0" VerticalAlignment="Top"
  4. HorizontalAlignment="Left">
  5. </TextBox>
You can set the border of a TextBox by using the BorderBrush property.
  1. <TextBox.BorderBrush>
  2. <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
  3. <GradientStop Color="Blue" Offset="0" />
  4. <GradientStop Color="Red" Offset="1.0" />
  5. </LinearGradientBrush>
  6. </TextBox.BorderBrush>
The Background and Foreground properties of the TextBox set the background and foreground colors of a TextBox.
  1. <TextBox.Background>
  2. <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
  3. <GradientStop Color="Blue" Offset="0.1" />
  4. <GradientStop Color="Orange" Offset="0.25" />
  5. <GradientStop Color="Green" Offset="0.75" />
  6. <GradientStop Color="Red" Offset="1.0" />
  7. </LinearGradientBrush>
  8. </TextBox.Background>
  9. <TextBox.Foreground>
  10. <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
  11. <GradientStop Color="Orange" Offset="0.25" />
  12. <GradientStop Color="White" Offset="1.0" />
  13. </LinearGradientBrush>
  14. </TextBox.Foreground>
To avoid duplicate content, this article has move here: WPF TextBox Tutorial