利用Trigger完成WPF 的動畫-漸顯

其實漸顯很簡單,就是改變控件的透明度。動畫

WPF提供了Trigger這個東西。spa

下面是動畫代碼:code

 
1
2
3
4
5
6
7
8
9
10
11
12
13
< Style x:Key = "BeginChildWindowStyle" TargetType = "{x:Type wtk:ChildWindow}" >
< Style.Triggers >
< Trigger Property = "wtk:ChildWindow.Visibility" Value = "Visible" >
< Trigger.EnterActions >
< BeginStoryboard >
< Storyboard Storyboard.TargetProperty = "Opacity" >
< DoubleAnimation From = "0" To = "1" Duration = "00:00:00.2" BeginTime = "00:00:00" />
</ Storyboard >
</ BeginStoryboard >
</ Trigger.EnterActions >
</ Trigger >
</ Style.Triggers >
</ Style >

TargetType="{x:Type wtk:ChildWindow}"指定了目標控件的類型
<Trigger Property="wtk:ChildWindow.Visibility" Value="Visible">指定了目標控件的屬性值爲Visible時觸發xml

相關文章
相關標籤/搜索