zoukankan      html  css  js  c++  java
  • silverlight制作虚线的边框

    <Grid>
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="g">
    <Canvas>
    <Rectangle RadiusX="5" RadiusY="5"
    Width="{Binding ElementName=g, Path=ActualWidth}"
    Height="{Binding ElementName=g, Path=ActualHeight}"
    Stroke="Blue" StrokeDashArray="5,2,1,2" StrokeThickness="2"/>
    </Canvas>
    <TextBlock Margin="10,7,10,7" Text="aaa" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
    </Grid>

    效果图:

    image

    公共样式:

     1 <Style TargetType="ContentControl" x:Key="myBorder">
     2 
     3 <Setter Property="Template">
     4 
     5 <Setter.Value>
     6 
     7 <ControlTemplate>
     8 
     9 <Grid x:Name="g"
    10 
    11 Background="{TemplateBinding ContentControl.Background}"
    12 
    13 Width="{TemplateBinding ContentControl.Width}"
    14 
    15 Height="{TemplateBinding ContentControl.Height}">
    16 
    17 <Canvas>
    18 
    19 <Rectangle RadiusX="5" RadiusY="5"
    20 
    21 Width="{Binding ElementName=g, Path=ActualWidth}"
    22 
    23 Height="{Binding ElementName=g, Path=ActualHeight}"
    24 
    25 Stroke="{TemplateBinding ContentControl.BorderBrush}"
    26 
    27 StrokeDashArray="5,2,1,2"
    28 
    29 StrokeThickness="{TemplateBinding ContentControl.BorderThickness}"/>
    30 
    31 </Canvas>
    32 
    33 <ContentPresenter Margin="5" Content="{TemplateBinding ContentControl.Content}"/>
    34 
    35 </Grid>
    36 
    37 </ControlTemplate>
    38 
    39 </Setter.Value>
    40 
    41 </Setter>
    42 
    43 </Style>

    http://www.cnblogs.com/sosoft/

    使用示例:

    <ContentControl Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center"

    BorderThickness="2" BorderBrush="Blue" Style="{StaticResource myBorder}">

    <TextBlock Text="abc"/>

    </ContentControl>

  • 相关阅读:
    Redis扩展功能
    Redis持久化
    redis-通讯协议及事件处理机制
    Redis-数据类型与底层数据结构
    分布式集群架构场景化解决方案
    MySQL-运维和第三方工具
    缓存原理&设计
    MySQL性能优化
    MySQL高级-日志常用的工具等等
    Mysql高级——优化
  • 原文地址:https://www.cnblogs.com/sosoft/p/3489927.html
Copyright © 2011-2022 走看看