WPF Silverlight Button样式

   <Button Width="75" Height="25" Content="查询" Foreground="White" Background="SlateGray">
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <Grid>

                        <Border Name="BackgroundAnimation" CornerRadius="2" Background="{TemplateBinding Background}"/>

                        <!--<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>-->

                        <!--应用此处可控制文字前景色 与下面Pressed中的 Storyboard.TargetName="ForegroundAnimation" 共同作用 与ContentPresenter部分相斥-->
                        <ContentControl Name="ForegroundAnimation" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Foreground="{TemplateBinding Foreground}"/>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimation Duration="0" To="Green" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"/>
                                    </Storyboard>
                                </VisualState>
                               
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimation Duration="0" To="Red" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"/>
                                        <ColorAnimation Duration="0" To="Yellow" Storyboard.TargetName="ForegroundAnimation" Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)"/>

                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>

                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>

                    </Grid>

 

                </ControlTemplate>
            </Button.Template>
        </Button>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值