这个是虚线边框的.
我是业余的,这个代码我自己看不懂的.用blend画的.
用blend画圆角文本框的:
======在blend中文本框的画法
=====================
资产->样式->简单样式(找到SimpleTextBox)->编辑当前->选中border,再属性栏里修改背景颜色(background)和边框颜色(borderBrush),修改圆角度(cornerRadius)[在外观那里]
如果画虚线的就选中border右键添加一个grid,把border的边框去掉,然后在grid里面画矩形,修改矩形的StrokeDashArray(一般我是2) StrokeDashLineCap="Square"(虚线两头的形状)
<Style x:Key="TextBoxStyle2" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid Margin="0,3,2,4">
<Rectangle Height="Auto" Margin="-1,0,0,0" RadiusY="4" RadiusX="4" StrokeStartLineCap="Triangle" StrokeEndLineCap="Square" Stroke="#FFF91212" StrokeThickness="2" StrokeMiterLimit="2" VerticalAlignment="Stretch" StrokeDashArray="2">
<Rectangle.Fill>
<SolidColorBrush Color="#FF0C50E2" Opacity="0.1"/>
</Rectangle.Fill>
</Rectangle>
<Border x:Name="bd" Margin="0" BorderBrush="#FFEC2929" BorderThickness="0" Padding="5,3,0,0" CornerRadius="15">
<Border.Background>
<SolidColorBrush Color="Black" Opacity="0"/>
</Border.Background>
<Grid Margin="0,0,2,0">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" BorderBrush="#FF28B43B" HorizontalAlignment="Left" Width="162.667" Margin="23.333,3.333,0,0"/>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
</MultiTrigger>
</Style.Triggers>
</Style>
调用:
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Margin="10,68.756,0,129.667" TextWrapping="Wrap" Width="195" Style="{DynamicResource TextBoxStyle2}" Text=""/>