虚线圆角文本框


这个是虚线边框的.

我是业余的,这个代码我自己看不懂的.用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=""/>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值