在好例子网,分享、交流、成长!
您当前所在位置:首页Sliverlight 开发实例SliverLight基础 → WPF vista类型的样式示例源码(ButtonStyle)

WPF vista类型的样式示例源码(ButtonStyle)

SliverLight基础

下载此实例
  • 开发语言:Sliverlight
  • 实例大小:0.56M
  • 下载次数:13
  • 浏览次数:246
  • 发布时间:2017-11-07
  • 实例类别:SliverLight基础
  • 发 布 人:nikki21
  • 文件格式:.rar
  • 所需积分:4
 相关标签: wpf wp t s

实例介绍

【实例简介】button style 透明、vista类型的样式

【实例截图】

from clipboard

【核心代码】


<Application x:Class="ButtonStyle.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Window1.xaml">
    <Application.Resources>
    	<ResourceDictionary>
            <!-- 引用资源字典 -->
    		<ResourceDictionary.MergedDictionaries>
    			<ResourceDictionary Source="Vista.xaml"/>
    			<ResourceDictionary Source="RadioButton.xaml"/>
    		</ResourceDictionary.MergedDictionaries>
            
    		<!-- Style1 -->
    		<Style x:Key="style1" TargetType="{x:Type Button}">
    			<Setter Property="Background" Value="Skyblue" />
    			<Setter Property="FontSize" Value="18" />
    			<Setter Property="FontFamily" Value="Verdena" />
    			<Setter Property="FontWeight" Value="Bold" />
    		</Style>

    		<!-- Style2 -->
    		<Style x:Key="style2" TargetType="{x:Type Button}">
    			<Setter Property="Background" Value="#FF99CC" />
    			<Setter Property="FontSize" Value="18" />
    			<Setter Property="FontFamily" Value="Verdena" />
    			<Setter Property="FontWeight" Value="Bold" />

    			<Setter Property="Template">
    				<Setter.Value>
    					<!--控件模板-->
    					<ControlTemplate TargetType="{x:Type Button}">
    						<!--背景色-->
    						<Border x:Name="back" Opacity="0.9" CornerRadius="3">
    							<Border.BitmapEffect>
    								<OuterGlowBitmapEffect Opacity="0.9" GlowSize="0" GlowColor="{Binding (Control.Background).(SolidColorBrush.Color), RelativeSource={RelativeSource TemplatedParent}}" />
    							</Border.BitmapEffect>
    							<Border.Background>
    								<LinearGradientBrush StartPoint="0,0" EndPoint="0,1.5">
    									<LinearGradientBrush.GradientStops>
    										<GradientStopCollection>
    											<GradientStop Color="{Binding (Control.Background).(SolidColorBrush.Color), RelativeSource={RelativeSource TemplatedParent}}" Offset="0"/>
    											<GradientStop Color="{Binding (Control.Background).(SolidColorBrush.Color), RelativeSource={RelativeSource TemplatedParent}}" Offset="0.4"/>
    											<GradientStop Color="#FFF" Offset="1"/>
    										</GradientStopCollection>
    									</LinearGradientBrush.GradientStops>
    								</LinearGradientBrush>
    							</Border.Background>
    							<!--前景色及边框-->
    							<Border x:Name="fore" BorderThickness="1" CornerRadius="3" BorderBrush="#5555">
    								<Border.Background>
    									<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
    										<LinearGradientBrush.GradientStops>
    											<GradientStopCollection>
    												<GradientStop Color="#6FFF" Offset="0.5"/>
    												<GradientStop Color="#1111" Offset="0.51"/>
    											</GradientStopCollection>
    										</LinearGradientBrush.GradientStops>
    									</LinearGradientBrush>
    								</Border.Background>
    								<!--按钮内容-->
    								<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}">
                                        <!-- 文字阴影效果 -->
    									<ContentPresenter.BitmapEffect>
    										<DropShadowBitmapEffect Color="#000" Direction="-45" ShadowDepth="5" Softness="0.1" Opacity="0.5" />
    									</ContentPresenter.BitmapEffect>
    								</ContentPresenter>
    							</Border>
    						</Border>
    						<!--触发器-->
    						<ControlTemplate.Triggers>
    							<!--鼠标移入移出-->
    							<Trigger Property="IsMouseOver" Value="True">
    								<Trigger.EnterActions>
    									<BeginStoryboard>
    										<Storyboard>
    											<DoubleAnimation To="10" Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />
    											<ColorAnimation To="#AFFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"/>
    											<ColorAnimation To="#3FFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"/>
    										</Storyboard>
    									</BeginStoryboard>
    								</Trigger.EnterActions>
    								<Trigger.ExitActions>
    									<BeginStoryboard>
    										<Storyboard>
    											<DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)"/>
    											<ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"/>
    											<ColorAnimation Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.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="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)"/>
    											<ColorAnimation To="#3AAA" Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"/>
    											<ColorAnimation To="#2111" Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"/>
    										</Storyboard>
    									</BeginStoryboard>
    								</Trigger.EnterActions>
    								<Trigger.ExitActions>
    									<BeginStoryboard>
    										<Storyboard>
    											<DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)"/>
    											<ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"/>
    											<ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"/>
    										</Storyboard>
    									</BeginStoryboard>
    								</Trigger.ExitActions>
    							</Trigger>
    							<!--按钮失效-->
    							<Trigger Property="IsEnabled" Value="False">
    								<Trigger.EnterActions>
    									<BeginStoryboard>
    										<Storyboard>
    											<DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)"/>
    											<DoubleAnimation To="1" Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(UIElement.BitmapEffect).(DropShadowBitmapEffect.Opacity)"/>
    											<DoubleAnimation To="-135" Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(UIElement.BitmapEffect).(DropShadowBitmapEffect.Direction)"/>
    											<ColorAnimation To="#FFF" Duration="0:0:0.3" Storyboard.TargetName="content" Storyboard.TargetProperty="(UIElement.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).(GradientBrush.GradientStops)[0].(GradientStop.Color)"/>
    											<ColorAnimation To="#CDDD" Duration="0:0:0.3" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"/>
    										</Storyboard>
    									</BeginStoryboard>
    								</Trigger.EnterActions>
    								<Trigger.ExitActions>
    									<BeginStoryboard>
    										<Storyboard>
    											<DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)"/>
    											<DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(UIElement.BitmapEffect).(DropShadowBitmapEffect.Opacity)"/>
    											<DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(UIElement.BitmapEffect).(DropShadowBitmapEffect.Direction)"/>
    											<ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="content" Storyboard.TargetProperty="(UIElement.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).(GradientBrush.GradientStops)[0].(GradientStop.Color)"/>
    											<ColorAnimation Duration="0:0:0.1" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"/>
    										</Storyboard>
    									</BeginStoryboard>
    								</Trigger.ExitActions>
    								<Setter Property="Foreground" Value="#B444"/>
    							</Trigger>
    						</ControlTemplate.Triggers>
    					</ControlTemplate>
    				</Setter.Value>
    			</Setter>
    		</Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>


标签: wpf wp t s

实例下载地址

WPF vista类型的样式示例源码(ButtonStyle)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警