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.
- <TextBox Name="TextBox1" Height="30" Width="200"
- Text="Hello! I am a TextBox."
- Margin="10,10,0,0" VerticalAlignment="Top"
- HorizontalAlignment="Left">
- </TextBox>
You can set the border of a TextBox by using the BorderBrush property.
- <TextBox.BorderBrush>
- <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
- <GradientStop Color="Blue" Offset="0" />
- <GradientStop Color="Red" Offset="1.0" />
- </LinearGradientBrush>
- </TextBox.BorderBrush>
The Background and Foreground properties of the TextBox set the background and foreground colors of a TextBox.
- <TextBox.Background>
- <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
- <GradientStop Color="Blue" Offset="0.1" />
- <GradientStop Color="Orange" Offset="0.25" />
- <GradientStop Color="Green" Offset="0.75" />
- <GradientStop Color="Red" Offset="1.0" />
- </LinearGradientBrush>
- </TextBox.Background>
- <TextBox.Foreground>
- <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
- <GradientStop Color="Orange" Offset="0.25" />
- <GradientStop Color="White" Offset="1.0" />
- </LinearGradientBrush>
- </TextBox.Foreground>