码迷,mamicode.com
首页 > Windows程序 > 详细

wpf 样式修改style和templant

时间:2016-05-10 18:03:42      阅读:938      评论:0      收藏:0      [点我收藏+]

标签:

1、模板的,只对某一个控件进行修改

<Button>
  <Button.Template>
    <ControlTemplate TargetType="Button">
      <Image x:Name="image" Source=".\button_up.png" />
      <ControlTemplate.Triggers>
        <Trigger Property="IsPressed" Value="True">
          <Setter TargetName="image" Property="Source" Value=".\button_down.png"/>
        </Trigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>
  </Button.Template>
</Button>

2、style的,对所有的相同的控件,属性进行修改

<Style TargetType="{x:Type Button}" x:Key="ButtonStyle">
        <Style.Triggers>
            <!--鼠标滑过按钮时按钮的发光效果-->
            <Trigger Property="Button.IsMouseOver" Value="True">
                <Trigger.Setters>
                    <Setter Property="Image.Effect">
                        <Setter.Value>
                            <DropShadowEffect BlurRadius="40" ShadowDepth="1" Color="White" Opacity="0.7"/>
                        </Setter.Value>
                    </Setter>
                </Trigger.Setters>
            </Trigger>
            <!--按钮按下时按下弹起效果-->
            <Trigger Property="Button.IsPressed" Value="True">
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <ScaleTransform ScaleX="0.95" ScaleY="0.95"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="RenderTransformOrigin" Value=".5,.5"/>
            </Trigger>
        </Style.Triggers>
    </Style>

 

wpf 样式修改style和templant

标签:

原文地址:http://www.cnblogs.com/Study02/p/5478363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!