首页 > 代码库 > (WPF)依赖属性
(WPF)依赖属性
属性触发器:
<Button MinWidth=" 75" Margin="10"> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="http://www.mamicode.com/True"> <Setter Property="Foreground" Value="http://www.mamicode.com/Blue"/> </Trigger> </Style.Triggers> </Style> </Button.Style> OK </Button>
数据触发器:
<Style TargetType="TextBlock"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Text}" Value="http://www.mamicode.com/8"> //使源元素为目标元素本身的TextBlock的Text属性。
// 满足条件:Value=http://www.mamicode.com/8"Foreground" Value="http://www.mamicode.com/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)依赖属性
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。