WPF自定义漂亮的按钮样式

首先打开 Microsoft Visual Studio 2008 ,新建一个WPF项目,在上面随便放几个按钮:

然后给各个按钮设置不同的背景颜色:

设置好之后就是这样啦:

然后我们就开始在 App.xaml 文件中定义按钮样式了:

定义的样式代码如下:

以下为引用的内容: <Application x:Class="WPFButton.App"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     StartupUri="Window1.xaml">     <Application.Resources>         <!--定义按钮样式-->         <Style TargetType="Button">             <Setter Property="Foreground" Value="Black"/>             <!--修改模板属性-->             <Setter Property="Template">                 <Setter.Value>                     <!--控件模板-->                     <ControlTemplate TargetType="Button">                         <!--背景色-->                         <Border x:Name="back" Opacity="0.8" CornerRadius="3">                             <Border.BitmapEffect>                                 <OuterGlowBitmapEffect Opacity="0.7" GlowSize="0" GlowColor="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" />                             </Border.BitmapEffect>                             <Border.Background>                                 <LinearGradientBrush StartPoint="0,0" EndPoint="0,1.5">                                     <GradientBrush.GradientStops>                                         <GradientStopCollection>                                             <GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0"/>                                             <GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4"/>                                             <GradientStop Color="#FFF" Offset="1"/>                                         </GradientStopCollection>                                     </GradientBrush.GradientStops>                                 </LinearGradientBrush>                             </Border.Background>                             <!--前景色及边框-->                             <Border x:Name="fore" BorderThickness="1" CornerRadius="3" BorderBrush="#5555">                                 <Border.Background>                                     <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">                                         <GradientBrush.GradientStops>                                             <GradientStopCollection>                                                 <GradientStop Color="#6FFF" Offset="0.5"/>                                                 <GradientStop Color="#1111" Offset="0.51"/>                                             </GradientStopCollection>                                         </GradientBrush.GradientStops>                                     </LinearGradientBrush>                                 </Border.Background>                                 <!--按钮内容-->                                 <ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding  Content}">                                     <ContentPresenter.BitmapEffect>                                         <DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" />                                     </ContentPresenter.BitmapEffect>                                 </ContentPresenter>                             </Border>                         </Border>                         <!--触发器-->                         <ControlTemplate.Triggers>                             <!--鼠标移入移出-->                             <Trigger Property="IsMouseOver" Value="True">                                 <Trigger.EnterActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation To="6" Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation To="#AFFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation To="#3FFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.EnterActions>                                 <Trigger.ExitActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.ExitActions>                             </Trigger>                             <!--按钮按下弹起-->                             <Trigger Property="IsPressed" Value="True">                                 <Trigger.EnterActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation To="3" Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation To="#3AAA" Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation To="#2111" Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.EnterActions>                                 <Trigger.ExitActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.ExitActions>                             </Trigger>                             <!--按钮失效-->                             <Trigger Property="IsEnabled" Value="False">                                 <Setter Property="Foreground" Value="#B444"/>                                 <Trigger.EnterActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <DoubleAnimation To="1" Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Opacity)" />                                             <DoubleAnimation To="-135" Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Direction)" />                                             <ColorAnimation To="#FFF" Duration="0:0:0.3" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Color)" />                                             <ColorAnimation To="#D555" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" />                                             <ColorAnimation To="#CEEE" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation To="#CDDD" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.EnterActions>                                 <Trigger.ExitActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Opacity)" />                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Direction)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.ExitActions>                             </Trigger>                         </ControlTemplate.Triggers>                     </ControlTemplate>                 </Setter.Value>             </Setter>         </Style>     </Application.Resources> </Application>

看了先不要头大,我们先看看最终效果,然后回过头来再解释代码:

这是常规样式

这个是鼠标移到上面时的样式

这个是鼠标点击时的样式

还有就是按钮失效时的样式

效果还算不错吧,下面来讲解代码喽,头晕的同学可以现在就收拾东西回家了哈。

我们先来看这个命名为“back”的 Border 元素,它用它的 Background 属性充当了整个按钮的背景色。

以下为引用的内容:

<Border.Background>                                 <LinearGradientBrush StartPoint="0,0" EndPoint="0,1.5">                                     <GradientBrush.GradientStops>                                         <GradientStopCollection>                                             <GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0"/>                                             <GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4"/>                                             <GradientStop Color="#FFF" Offset="1"/>                                         </GradientStopCollection>                                     </GradientBrush.GradientStops>                                 </LinearGradientBrush>                             </Border.Background>

其背景所用的是一个渐变笔刷,起始值和中间值都是引用的按钮本身的背景色,就是我们之前设置过的颜色啦,终止值是白色,这样通过位置调整,我们可以在按钮最下部产生一些向白色的过度色彩效果。

以下为引用的内容: <Border.BitmapEffect>                                 <OuterGlowBitmapEffect Opacity="0.7" GlowSize="0" GlowColor="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" />                             </Border.BitmapEffect>

它的 BitmapEffect 属性我们设置了一个大小为 0 的外发光效果,平常是看不见这效果的,在这里预先设置好,是为了在鼠标移入、按下时实现动画使用。

再来看看这个命名为“fore”的 Border 元素,它实现的是按钮的边框和高亮反光效果,我为它设置了一个半透明的黑色1像素边框,使得这个边框的色彩可以和背景色混合起来。

以下为引用的内容:  <Border.Background>                                     <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">                                         <GradientBrush.GradientStops>                                             <GradientStopCollection>                                                 <GradientStop Color="#6FFF" Offset="0.5"/>                                                 <GradientStop Color="#1111" Offset="0.51"/>                                             </GradientStopCollection>                                         </GradientBrush.GradientStops>                                     </LinearGradientBrush>                                 </Border.Background>

它的背景同样采用的渐变笔刷,起始值和终止值的位置几乎贴在一起,从而形成比较鲜明的反光度对比。

ContentPresenter 元素用于呈现按钮原本的内容,对于按钮来说就是按钮上的文字了,当然也可能会存在图片或其它东西。

以下为引用的内容:  <ContentPresenter.BitmapEffect>                                         <DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" />                                     </ContentPresenter.BitmapEffect>

我为之加了一个不太明显的阴影滤镜以增强显示效果。

剩下的就是些可爱又该死的 Trigger ,我们通过这些触发器来改变按钮在不同状态时的外观。

以下为引用的内容:       <!--鼠标移入移出-->                             <Trigger Property="IsMouseOver" Value="True">                                 <Trigger.EnterActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation To="6" Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation To="#AFFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation To="#3FFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.EnterActions>                                 <Trigger.ExitActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.ExitActions>                             </Trigger>

在鼠标移入按钮时,我依次创建了改变外发光效果大小、改变上部反光区域颜色、改变下部反光区域颜色的动画,这里的要点就在于“Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)"”属性设置语句,琢磨一下你就能看出这是对属性路径的描述,只不过它们写起来和看起来都很让人生气。

以下为引用的内容:                        <!--按钮按下弹起-->                             <Trigger Property="IsPressed" Value="True">                                 <Trigger.EnterActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation To="3" Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation To="#3AAA" Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation To="#2111" Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.EnterActions>                                 <Trigger.ExitActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.ExitActions>                             </Trigger>

按下和弹起按钮时,我们做了相似的动画改变,与前面相比只是数值略微不同。

以下为引用的内容: <!--按钮失效-->                             <Trigger Property="IsEnabled" Value="False">                                 <Setter Property="Foreground" Value="#B444"/>                                 <Trigger.EnterActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <DoubleAnimation To="1" Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Opacity)" />                                             <DoubleAnimation To="-135" Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Direction)" />                                             <ColorAnimation To="#FFF" Duration="0:0:0.3" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Color)" />                                             <ColorAnimation To="#D555" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" />                                             <ColorAnimation To="#CEEE" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation To="#CDDD" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.EnterActions>                                 <Trigger.ExitActions>                                     <BeginStoryboard>                                         <Storyboard>                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Opacity)" />                                             <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Direction)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(ContentPresenter.BitmapEffect).(DropShadowBitmapEffect.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />                                             <ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />                                         </Storyboard>                                     </BeginStoryboard>                                 </Trigger.ExitActions>                             </Trigger>

当按钮失效时,我要改变很多东西,首先将文字颜色设为灰色,然后依次创建了改变外发光效果大小、改变内容阴影效果不透明度、改变内容阴影效果角度、改变内容阴影效果颜色、改变按钮边框颜色、改变上部反光区域颜色、改变下部反光区域颜色的动画。

这里将先前对内容应用的阴影效果彻底改变,使之产生凹陷的效果。

好了,到这里就下课啦,文章有点冗长了,但应该对新手很有帮助,老鸟估计现在已经梦游仙境了吧。

时间: 2024-10-27 06:30:14

WPF自定义漂亮的按钮样式的相关文章

自定义新浪微博分享按钮样式

自定义新浪微博分享按钮样式 新浪开放平台虽然有分享按钮的组件(http://open.weibo.com/sharebutton)并且提供了两种格式的应用方法:WBML和JS,但还是无法据自己的需求做到自定义样式. 为了解决该问题,我们首先来看下新浪所生成的JS代码: <script type="text/javascript" charset="utf-8"> (function(){ var _w = 32 , _h = 32; var param

wpf 自定义RadioButton控件样式

实现的效果为: 我感觉来自定义RadioButton样式和定义button空间的样式差不多,只是类型不同而已. 接下来分析一下样式代码: <!--自定义单选按钮样式-->        <Style TargetType="RadioButton"> <Setter Property="Template">                <Setter.Value>                    <Con

Easyui 自定义列 添加按钮 样式问题

开始想在easyui的datgrid中添加一列操作列,这一列的内容全部是按钮,方便显示详细信息. 添加完成之后,发现按钮的样式有问题,即使我把a标签的class属性和plain属性设置成和页面上一样,结果还是没有起作用. 开始的部分代码: onLoadSuccess:function(data){ }, idField:'userId', columns:[[ {field:'ck',width:5,checkbox:true}, {field:'userId',title:'用户id',wid

WPF 自定义TabControl控件样式

一.前言 程序中经常会用到TabControl控件,默认的控件样式很普通.而且样式或功能不一定符合我们的要求.比如:我们需要TabControl的标题能够居中.或平均分布:或者我们希望TabControl的标题能够进行关闭.要实现这些功能我们需要对TabControl的样式进行定义. 二.实现TabControl的标题平均分布 默认的TabControl标题是使用TabPanel容器包含的.要想实现TabControl标题头平均分布,需要把TabPanel替换成UniformGrid: 替换后的

自定义上传按钮样式

效果体验:http://runjs.cn/detail/crltmoya <!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style> #fileInput1 { cursor:pointer; opacity:0; } div{ width:300px; height:200px; backgroun

WPF自定义样式篇-DataGrid

WPF自定义样式篇-DataGrid 先上效果图: 样式: <!--DataGrid样式-->    <Style TargetType="DataGrid">        <Setter Property="RowHeaderWidth" Value="0"></Setter>        <Setter Property="AutoGenerateColumns"

WPF 自定义滚动条样式

先看一下效果: 先分析一下滚动条有哪儿几部分组成: 滚动条总共有五部分组成: 两端的箭头按钮,实际类型为RepeatButton Thumb 两端的空白,实际也是RepeatButton 最后就是Thumb(滑块) 所以如果要修改滚动条的样式,就要修改这五部分的样式.具体代码如下: <!--自定义滚动条样式-->            <SolidColorBrush x:Key="StandardBorderBrush"                       

WPF:自定义Metro样式文件夹选择对话框FolderBrowserDialog

1.前言 WPF并没有文件选择对话框,要用也就只有使用Winform版的控件.至今我也没有寻找到一个WPF版本的文件选择对话框. 可能是我眼浊,如果各位知道有功能比较健全的WPF版文件选择对话框.文件打开对话框,还请留言告知. 这次做的是一个精简版的文件选择对话框.包含一个UserControl和一个承载UserControl的Window. 另外TreeView的样式引用自Mahspps中的样式.也就是如果需要使用这个文件选择对话框,就必须要引用Mahapps的相关dll. 当然,我会提供整个

36种漂亮的网页Button按钮样式

本页面向大家展开了36种漂亮的网页Button按钮样式,各式各样的都有,适合不同的场合使用.CSS3技术的确非常强大,不过大家测试的时候不要使用IE8,因为IE8还没有完全支持css3,微软如此不屑CSS3,唉!请使用火狐或Safari或Google Chrome. 1 <!DOCTYPE HTML> 2 <html lang="en-US"> 3 <head> 4 <meta charset="UTF-8"> 5 &