WPF开发工具的推出为我们带来了新一代的开发模式,开发人员摆脱了图形界面设计的局限性,可以轻松的实现精美的图形界面。下面我们就来看看WPF TextBox的使用方法#t#
默认和修改WPF TextBox控件中Template后的显示
- < Style TargetType="
{x:Type TextBox}"> - < Setter Property="Template">
- < Setter.Value>
- < ControlTemplate TargetType=
"{x:Type TextBox}"> - < Grid>
- < Border Background=
"{TemplateBinding Background}"
CornerRadius="5" /> - < Rectangle RadiusX="5"
RadiusY="5" Width="10"
HorizontalAlignment="Left"> - < Rectangle.Fill>
- < LinearGradientBrush
StartPoint="0,0" EndPoint="1,0"> - < LinearGradientBrush.GradientStops >
- < GradientStop Offset="0"
Color="Black" /> - < GradientStop Offset="0.3"
Color="YellowGreen" /> - < GradientStop Offset="1"
Color="Transparent" /> - < /LinearGradientBrush.GradientStops>
- < /LinearGradientBrush>
- < /Rectangle.Fill>
- < /Rectangle>
- < Rectangle RadiusX="5" RadiusY="5"
Height="10" Margin="3,0,0,0"
VerticalAlignment="Top" > - < Rectangle.Fill>
- < LinearGradientBrush StartPoint="0,0"
EndPoint="0,1"> - < LinearGradientBrush.GradientStops >
- < GradientStop Offset="0" Color="Black" />
- < GradientStop Offset="0.3"
Color="YellowGreen" /> - < GradientStop Offset="1"
Color="Transparent" /> - < /LinearGradientBrush.
GradientStops> - < /LinearGradientBrush>
- < /Rectangle.Fill>
- < /Rectangle>
- < Border CornerRadius="5"
BorderBrush="Black" BorderThickness="1" /> - < ScrollViewer Name="PART_ContentHost"
Margin="2" /> - < Border CornerRadius="6,6,0,0"
Height="15" VerticalAlignment="Top"> - < Border.Background>
- < LinearGradientBrush StartPoint="0,0"
EndPoint="0,1"> - < LinearGradientBrush.GradientStops >
- < GradientStop Offset="0"
Color="#60FFFFFF" /> - < GradientStop Offset="0.7"
Color="#40FFFFFF" /> - < /LinearGradientBrush.GradientStops>
- < /LinearGradientBrush>
- < /Border.Background>
- < /Border>
- < /Grid>
- < /ControlTemplate>
- < /Setter.Value>
- < /Setter>
- < /Style>
以上就是WPF TextBox的相关使用方法介绍。