zoukankan      html  css  js  c++  java
  • ControlTemple样式

    1.TextBox 样式

    1.1 style

     1    <Window.Resources>
     2         <Style x:Key="aa" TargetType="{x:Type TextBox}">
     3             <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
     4             <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
     5             <Setter Property="BorderThickness" Value="1"/>
     6             <Setter Property="Padding" Value="1"/>
     7             <Setter Property="AllowDrop" Value="true"/>
     8             <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
     9             <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
    10             <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
    11             <Setter Property="Template">
    12                 <Setter.Value>
    13                     <ControlTemplate TargetType="{x:Type TextBox}">
    14                         <!--外边框颜色之类设置-->
    15                         <Border x:Name="Bd"  CornerRadius="23" Padding="1" BorderBrush="#FFDDDDDD" BorderThickness="2"  >
    16                             <Border.Effect>
    17                                 <DropShadowEffect BlurRadius="10" Color="#FFE5F2FC" Direction="0" ShadowDepth="0"/>
    18                             </Border.Effect>
    19                             <!--这个Border主要用来遮挡框内的阴影,只要外阴影,如果只要内阴影不要外阴影,那么设置border的 ClipToBounds="True"  剪切外部内容,即可实现内阴影-->
    20                             <Border Background="White" CornerRadius="23">
    21                                 <ScrollViewer x:Name="PART_ContentHost" Margin="5,0"  VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}"/>
    22                             </Border>
    23                         </Border>
    24                         <ControlTemplate.Triggers>
    25                             <!--当鼠标移入输入框-->
    26                             <Trigger Property="IsMouseOver" Value="True">
    27                                 <Setter Property="BorderBrush" TargetName="Bd" Value="#FF66AFE9"/>
    28                             </Trigger>
    29                          <!--当输入框获得焦点-->
    30                             <Trigger Property="IsFocused" Value="True">
    31                                 <!--外边框阴影设置-->
    32                                 <Setter Property="Effect" TargetName="Bd">
    33                                     <Setter.Value>
    34                                         <DropShadowEffect BlurRadius="10" Color="#FFE5F2FC" Direction="0" ShadowDepth="0"/>
    35                                     </Setter.Value>
    36                                 </Setter>
    37                                 <Setter Property="BorderBrush" TargetName="Bd" Value="#FF66AFE9"/>
    38                             </Trigger>
    39                             
    40                         </ControlTemplate.Triggers>
    41                     </ControlTemplate>
    42                 </Setter.Value>
    43             </Setter>
    44         </Style>
    45 
    46     </Window.Resources>
    47     <StackPanel>
    48         <TextBox Margin="10" Style="{StaticResource aa}"  FontSize="17" Height="50" Width="200"  Foreground="Black"/>
    49         <TextBox Margin="10" Style="{StaticResource aa}"  FontSize="17" Height="50" Width="200"  Foreground="Black"/>
    50 
    51     </StackPanel>
    View Code

    样式

  • 相关阅读:
    Nhibernate初学
    TSQL笔记
    Java是剑客飘逸;.NET是刀客霸道 (一) 【转载】
    在datagrid中求和(vb.net,c#)
    Java牢骚之我见(转载)
    Java是剑客飘逸;.NET是刀客霸道 (二) 【转载】
    可可西里观后感(转)保护藏羚羊
    .net快速入门方法,转csdn
    手工添加“显示桌面”快捷方式
    过年128>24
  • 原文地址:https://www.cnblogs.com/lizhenlin/p/6021359.html
Copyright © 2011-2022 走看看