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

(WPF)依赖属性

时间:2015-07-25 15:22:16      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:



属性触发器:

        <Button MinWidth=" 75" Margin="10">
                       
            <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="Blue"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
                
                    OK
        </Button>

数据触发器:


        <Style TargetType="TextBlock">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Text}" Value="8">    //使源元素为目标元素本身的TextBlock的Text属性。
                                                                                                                  // 满足条件:Value=8
                    <Setter Property="Foreground"
                            Value="Red"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <TextBlock Height="Auto"
                   HorizontalAlignment="Center"
                   Margin="0"
                   Name="textBlock1"
                   Text="8"
                   VerticalAlignment="Center"
                   Grid.Row="1" />




事件触发器:

  <Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
      <EventTrigger.Actions>         
        <BeginStoryboard>
          <Storyboard SpeedRatio="1">
              
            <DoubleAnimation Storyboard.TargetName="element"
                                Storyboard.TargetProperty="Opacity"
                                From="0.2" To="1" Duration="0:0:2.5"></DoubleAnimation>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger.Actions>      
    </EventTrigger>
  </Window.Triggers>


版权声明:本文为博主原创文章,未经博主允许不得转载。

(WPF)依赖属性

标签:

原文地址:http://blog.csdn.net/ilipan/article/details/47053105

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