TextBox

  1. <Window x:Class="WpfDemo.ListBoxTemaple"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. Title="ListBoxTemaple" Height="" Width="" >
  5. <Window.Resources>
  6. <Style x:Key="TextBoxStyle1" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
  7. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  8. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
  9. <Setter Property="BorderThickness" Value=""/>
  10. <Setter Property="Padding" Value=""/>
  11. <Setter Property="AllowDrop" Value="true"/>
  12. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  13. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  14. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type TextBox}">
  18. <Border x:Name="Bd" SnapsToDevicePixels="true" BorderBrush="#FFDDDDDD" BorderThickness="" ClipToBounds="False" CornerRadius="">
  19. <Border.Effect>
  20. <DropShadowEffect Color="White" Direction="" ShadowDepth="" BlurRadius=""/>
  21. </Border.Effect>
  22. <!--这个Border主要用来遮挡框内的阴影,只要外阴影,如果只要内阴影不要外阴影,那么设置border的 ClipToBounds="True" 剪切外部内容,即可实现内阴影-->
  23. <Border Background="White" CornerRadius="">
  24. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
  25. </ScrollViewer>
  26. </Border>
  27. </Border>
  28. <ControlTemplate.Triggers>
  29.  
  30. <Trigger Property="IsMouseOver" Value="True">
  31. <Setter Property="BorderBrush" TargetName="Bd" Value="#FF66AFE9"/>
  32. </Trigger>
  33.  
  34. <Trigger Property="IsFocused" Value="True">
  35. <Setter Property="Effect" TargetName="Bd">
  36. <Setter.Value>
  37. <DropShadowEffect BlurRadius="" Color="#FFE5F2FC" Direction="" ShadowDepth=""/>
  38. </Setter.Value>
  39. </Setter>
  40. <Setter Property="BorderBrush" TargetName="Bd" Value="#FF66AFE9"/>
  41. </Trigger>
  42.  
  43. </ControlTemplate.Triggers>
  44. </ControlTemplate>
  45. </Setter.Value>
  46. </Setter>
  47. </Style>
  48. </Window.Resources>
  49. <Grid>
  50.  
  51. <TextBox Text="四川" Grid.Column="" Grid.Row="" BorderBrush="{x:Null}" Background="{x:Null}" SelectionBrush="#FFE237EA" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Style="{DynamicResource TextBoxStyle1}" Height="" Width="" Margin="4,5,0,5" />
  52. </Grid>
  53. </Window>

  1. <Window x:Class="WpfFormControl.Window1"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. Title="ListBoxTemaple" Height="" Width="" >
  5. <Window.Resources>
  6. <Style x:Key="ComboBoxReadonlyToggleButton" TargetType="{x:Type ToggleButton}">
  7. <Setter Property="OverridesDefaultStyle" Value="true"/>
  8. <Setter Property="ClickMode" Value="Press"/>
  9. <Setter Property="Background" Value="Transparent"/>
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="{x:Type ToggleButton}">
  13. <Border x:Name="border1" ClipToBounds="True" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="" CornerRadius=""
  14. Background="#01ffffff">
  15. <Border.Effect>
  16. <DropShadowEffect BlurRadius="" ShadowDepth="" Color="#FFF9F7F7" />
  17. </Border.Effect>
  18.  
  19. <Grid>
  20. <Grid.ColumnDefinitions>
  21. <ColumnDefinition />
  22. <ColumnDefinition Width="" />
  23. </Grid.ColumnDefinitions>
  24.  
  25. <Border x:Name="border" Grid.Column="" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,0,0,0" Background="{x:Null}">
  26. <Path x:Name="Arrow" Grid.Column="" HorizontalAlignment="Center" VerticalAlignment="Center" Width="" Height="10.25" Data="M 0 0 L 4 4 L 8 0 Z" Stretch="Fill" Fill="#FFEB5948" />
  27. </Border>
  28. </Grid>
  29. </Border>
  30. <ControlTemplate.Triggers>
  31. <Trigger Property="IsMouseOver" Value="True">
  32. <Setter Property="BorderBrush" TargetName="border1" Value="#FF66AFE9"/>
  33. </Trigger>
  34. <Trigger Property="IsMouseOver" Value="True">
  35. <Setter Property="BorderBrush" TargetName="border1" Value="#FF66AFE9"/>
  36. </Trigger>
  37. <Trigger Property="IsMouseOver" Value="True" SourceName="border">
  38. <Setter Property="Fill" TargetName="Arrow" Value="#FFC91E64"/>
  39. </Trigger>
  40. <Trigger Property="IsChecked" Value="true">
  41. <!--<Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>-->
  42. </Trigger>
  43. <Trigger Property="IsEnabled" Value="false">
  44. <Setter Property="Fill" TargetName="Arrow" Value="#AFAFAF"/>
  45. </Trigger>
  46. </ControlTemplate.Triggers>
  47. </ControlTemplate>
  48. </Setter.Value>
  49. </Setter>
  50. </Style>
  51.  
  52. <Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}">
  53. <Setter Property="BorderThickness" Value=""/>
  54. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  55. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  56. <Setter Property="Padding" Value="4,3"/>
  57. <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
  58. <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
  59. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  60. <Setter Property="ItemContainerStyle">
  61. <Setter.Value>
  62. <!--ComBoxItem-->
  63. <Style TargetType="ComboBoxItem">
  64. <Setter Property="MinHeight" Value=""></Setter>
  65. <Setter Property="MinWidth" Value=""></Setter>
  66. <Setter Property="Template">
  67. <Setter.Value>
  68. <ControlTemplate TargetType="ComboBoxItem">
  69. <Border Name="Back" Background="Transparent" BorderThickness="0,0,0,0" BorderBrush="#81D779" Height="" >
  70. <!--<ContentPresenter ContentSource="{Binding Source}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter>-->
  71. <ContentPresenter ContentSource="{Binding Source}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter>
  72.  
  73. </Border>
  74. <ControlTemplate.Triggers>
  75. <Trigger Property="IsMouseOver" Value="True">
  76. <Setter TargetName="Back" Property="Background" Value="LightGray"></Setter>
  77. </Trigger>
  78. <Trigger Property="IsHighlighted" Value="True">
  79. <Setter TargetName="Back" Property="Background" Value="LightGray"></Setter>
  80. </Trigger>
  81. </ControlTemplate.Triggers>
  82. </ControlTemplate>
  83. </Setter.Value>
  84. </Setter>
  85. </Style>
  86. </Setter.Value>
  87. </Setter>
  88. <Setter Property="Template">
  89. <Setter.Value>
  90. <ControlTemplate TargetType="{x:Type ComboBox}">
  91. <Grid x:Name="MainGrid" SnapsToDevicePixels="true" FocusVisualStyle="{x:Null}" Background="White" >
  92. <Grid.ColumnDefinitions>
  93. <ColumnDefinition Width="*"/>
  94. <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width=""/>
  95. </Grid.ColumnDefinitions>
  96. <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
  97. <Border CornerRadius="" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
  98. <Border.Effect>
  99. <DropShadowEffect Color="Black" BlurRadius="" ShadowDepth="" Opacity="0.5"/>
  100. </Border.Effect>
  101. <ScrollViewer Margin="1,2,2,6" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
  102. <!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
  103. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="White"/>
  104. </ScrollViewer>
  105. </Border>
  106. </Popup>
  107.  
  108. <ToggleButton x:Name="toggleButton" FocusVisualStyle="{x:Null}" BorderBrush="#FFDDDDDD" Grid.ColumnSpan="" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxReadonlyToggleButton}" />
  109. <TextBox Text="{TemplateBinding SelectionBoxItem}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" BorderThickness="" BorderBrush="{x:Null}" Background="Transparent" SelectionBrush="#FFFF334F" IsReadOnly="True" Cursor="Arrow" FocusVisualStyle="{x:Null}" ></TextBox>
  110. <ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  111. </Grid>
  112. <ControlTemplate.Triggers>
  113.  
  114. <Trigger Property="IsMouseOver" Value="True">
  115. <Setter Property="BorderBrush" TargetName="toggleButton" Value="#FF66AFE9"/>
  116. </Trigger>
  117.  
  118. <Trigger Property="IsEnabled" Value="false">
  119. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  120. <Setter Property="Background" Value="#FFF4F4F4"/>
  121. </Trigger>
  122. <Trigger Property="IsGrouping" Value="true">
  123. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  124. </Trigger>
  125.  
  126. </ControlTemplate.Triggers>
  127. </ControlTemplate>
  128. </Setter.Value>
  129. </Setter>
  130. <Style.Triggers>
  131. <Trigger Property="IsEditable" Value="true">
  132. <!--<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>-->
  133. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
  134. <Setter Property="IsTabStop" Value="false"/>
  135. <Setter Property="Padding" Value=""/>
  136. </Trigger>
  137. </Style.Triggers>
  138. </Style>
  139. <!--Combobox里ToggleButton的样式-->
  140.  
  141. </Window.Resources>
  142. <Grid>
  143.  
  144. <!--引用样式-->
  145. <ComboBox Height="" Width="" FocusVisualStyle="{x:Null}" Style="{DynamicResource ComboBoxStyle1}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="4,5,0,5">
  146. <ListBoxItem></ListBoxItem>
  147. <ListBoxItem></ListBoxItem>
  148. <ListBoxItem></ListBoxItem>
  149. <ListBoxItem></ListBoxItem>
  150. <ListBoxItem></ListBoxItem>
  151. </ComboBox>
  152. </Grid>
  153. </Window>

WPF 常用样式的更多相关文章

  1. WPF常用样式总结

    常用控件样式: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation ...

  2. 记录一些WPF常用样式方便以后复用(二)(Button、CheckBox、输入账号密码框)(转)

    Button (一) <Style x:Key="ButtonSaveStyle" TargetType="{x:Type Button}"> &l ...

  3. 记录一些WPF常用样式方便以后复用(转)

    TextBox文本框 <Style x:Key="TextBoxStyle1" BasedOn="{x:Null}" TargetType="{ ...

  4. 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇一:WPF常用知识以及本项目设计总结

    篇一:WPF常用知识以及本项目设计总结:http://www.cnblogs.com/baiboy/p/wpf.html 篇二:基于OneNote难点突破和批量识别:http://www.cnblog ...

  5. WPF常用控件应用demo

    WPF常用控件应用demo 一.Demo 1.Demo截图如下: 2.demo实现过程 总体布局:因放大缩小窗体,控件很根据空间是否足够改变布局,故用WrapPanel布局. <ScrollVi ...

  6. wpf 导出Excel Wpf Button 样式 wpf简单进度条 List泛型集合对象排序 C#集合

    wpf 导出Excel   1 private void Button_Click_1(object sender, RoutedEventArgs e) 2 { 3 4 ExportDataGrid ...

  7. WPF中样式和行为和触发器

    原文:WPF中样式和行为和触发器 样式简介:样式(style)是组织和重用格式化选项的重要工具,不是使用重复的标记填充XAML,以便设置外边距.内边距.颜色以及字体等细节.而是创建一系列封装所有这些细 ...

  8. CSS/CSS3常用样式小结

    1.强制文本单行显示: white-space:nowrap; 多行文本最后省略号: display: -webkit-box; -webkit-line-clamp:2; overflow: hid ...

  9. CSS常用样式及示例

    CSS常用样式及示例 一.简介      层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集) ...

随机推荐

  1. linux 查看日志

    第一步 :提交自己目录文件(先到自己目录下载最新文件-->合并-->提交到临时目录temp-->在提交到master总目录-->其他关联master远 程分支的目录.就可以pu ...

  2. Bootstrap介绍

    Bootstrap是基于HTML.CSS和JavaScript开源的前端开发工具包. 1.响应式布局: 效果:根据浏览器的宽度来调整页面布局. 例如: <html lang="en&q ...

  3. 聊天系统Demo,增加Silverlight客户端(附源码)-- ESFramework 4.0 快速上手(09)

    在ESFramework 4.0 快速上手 -- 入门Demo,一个简单的IM系统(附源码)一文中,我们介绍了使用ESFramework的Rapid引擎开发的winform聊天程序,本文我们将在之前d ...

  4. C -小晴天老师系列——竖式乘法

    C - 小晴天老师系列——竖式乘法 Time Limit: 4000/2000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Others ...

  5. a标签中使用img后的高度多了几个像素

    a元素下有一个匿名文本,这个文本外有一个匿名行级盒子,它有的默认vertical-align是baseline的,而且往往因为上文line-height的影响,使它有个line-height,从而使其 ...

  6. ubuntn安装五笔输入法

    1.首先要把原来的 ibus 卸载掉 sudo apt-get remove ibus 2.添加源 sudo add-apt-repository ppa:fcitx-t(www.111cn.net) ...

  7. 什么是JDBC?

    JDBC是Java数据库连接(Java DataBase Connectivity)技术的简称,提供连接各种常用数据库的能力! 1.方式一(配置文件实现): <!-- 1. 连接池实例 --&g ...

  8. Adobe flash CC 汉化破解方法

    转载整理自:http://www.sdifenzhou.com/flashprofessionalcc.html 断网,解压下载的破解dmg文件得到这些文件 第一步,解压安装包,安装,并打开,不要输入 ...

  9. php 模拟浏览器get和post提交处理

    文件夹test下index.php <?phpheader("Content-Type: text/html;charset=gb2312"); function cUrlG ...

  10. 2.Add Two Numbers-两个单链表相加

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...