LGED

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

第一种

<Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded" >
        <BeginStoryboard>
            <Storyboard>
                <DoubleAnimation Duration="00:00:01" Storyboard.TargetProperty="Opacity" From="0" To="1" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>

 

第二种

<Window.Resources>
    <Storyboard x:Key="showMe">
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
        </ObjectAnimationUsingKeyFrames>
        <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:1" To="0.75"/>
    </Storyboard>
    <Storyboard x:Key="hideMe">
    <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:1" To="0.0"/>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
        <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{x:Static Visibility.Hidden}"/>
    </ObjectAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>

 

public new void Show()
{
    (FindResource("showMe") as System.Windows.Media.Animation.Storyboard).Begin(this);
}
public new void Hide()
{
    (FindResource("hideMe") as System.Windows.Media.Animation.Storyboard).Begin(this);
}

 

posted on 2015-11-24 22:48  LGED  阅读(2242)  评论(0编辑  收藏  举报