[WPF] TextBox Metro风格样式
2014-01-05 12:35
381 查看
很多时候在项目中想有一个简单的,没有那么花哨的文本框,这时我们会想到使用图片来修饰,但是其实这样就是累赘!
简单的风格,简单的代码,简单的样式,其实就很好!
名称:
Metro 风格TextBox
属性:
鼠标没有悬上去的时候是TextBlock,
悬上去是有背景的TextBlock+半透明白色边框,
当选中的时候可以输入,
TextBlock状态背景透明,
选中时候背景为半透明黑色,
加半透明白色边框
代码:
下载:
资源下载
简单的风格,简单的代码,简单的样式,其实就很好!
名称:
Metro 风格TextBox
属性:
鼠标没有悬上去的时候是TextBlock,
悬上去是有背景的TextBlock+半透明白色边框,
当选中的时候可以输入,
TextBlock状态背景透明,
选中时候背景为半透明黑色,
加半透明白色边框
代码:
<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}"> <Setter Property="Background" Value="{x:Null}"/> <Setter Property="BorderBrush" Value="{x:Null}"/> <Setter Property="Foreground" Value="White"/> <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="HorizontalContentAlignment" Value="Left"/> <Setter Property="Padding" Value="0.5,0"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="AllowDrop" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Border x:Name="BackBorder" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" Background="{x:Null}" BorderBrush="{x:Null}"> <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Background" TargetName="BackBorder" Value="{x:Null}"/> <Setter Property="Foreground" Value="#CCFFFFFF"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" TargetName="BackBorder" Value="#30FFFFFF"/> <Setter Property="BorderBrush" TargetName="BackBorder" Value="#30FFFFFF"/> </Trigger> <Trigger Property="IsFocused" Value="True"> <Setter Property="Background" TargetName="BackBorder" Value="#30000000"/> <Setter Property="BorderBrush" TargetName="BackBorder" Value="#50FFFFFF"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
下载:
资源下载
相关文章推荐
- 潜移默化学会WPF(样式篇)---改造ComboBox,全新metro风格
- 潜移默化学会WPF(样式篇)---改造CheckBox,全新metro风格
- Windows Phone, Win 8/WPF, Windows Form 的ItemsControl的ItemTemplate模版和Style风格多样化[自定义逻辑样式]
- WPF:Metro样式ProgressBar(圆点横向移动),自适应宽度
- 将win8 Metro风格界面开始菜单转换成win7样式具体操作步骤
- 让WPF的TextBox控件可以使用System.Windows.Forms.FontDialog设置样式
- WPF中的Style(风格,样式)
- WPF--TextBox样式使用(文字居中、背景、圆角...)
- WPF中的Style(风格,样式)
- Bootstrap WPF Style,Bootstrap风格的WPF样式
- WPF中的Style(风格,样式)
- 艾伟:WPF中的Style(风格,样式)
- Bootstrap风格的WPF样式
- 一分钟将你的WPF应用程序变身成炫彩动态Metro风格
- wpf实现metrol风格的Treeview样式
- WPF:自定义Metro样式文件夹选择对话框FolderBrowserDialog
- WPF中的Style(风格,样式)
- WPF中的Style(风格,样式)
- WPF中的Style(风格,样式)
- WPF中的Style(风格,样式)