• Storyboard 学习


    private Storyboard PrepareShowStory()
            {
                Storyboard story = new Storyboard();
                DoubleAnimation animation;

                animation = new DoubleAnimation();
                animation.From = 0;
                animation.To = 100;
                animation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
                Storyboard.SetTarget(animation, image1);
                //Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)"));
                Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Height)"));
                story.Children.Add(animation);

               

                story.AutoReverse = true;
                story.RepeatBehavior = new RepeatBehavior(3); //RepeatBehavior.Forever;

                return story;
            }

    story.AutoReverse

    是否返回,如上面的,先是从0到100,然后再自动由100到0

    animation.Duration 执行的间隔

    <!--LayoutRoot 是包含所有页面内容的根网格-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--TitlePanel 包含应用程序的名称和页标题-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock x:Name="ApplicationTitle" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock x:Name="PageTitle" Text="页面名称" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
            <Popup x:Name="ProgressPopup" Width="300" IsOpen="False" HorizontalAlignment="Center" 
                       VerticalAlignment
    ="Top" d:LayoutOverrides="Width, HorizontalMargin" Margin="89,203,91,0">
                <Border BorderThickness="10" BorderBrush="Black" Background="DarkGray" Padding="30,30">
                    <StackPanel>
                        <TextBlock MaxHeight="100" Foreground="White"  FontWeight="Bold"  FontSize="36" x:Name="txt" Text="1">
                                <TextBlock.Triggers> 
                                    <EventTrigger RoutedEvent="TextBlock.Loaded"> 
                                        <BeginStoryboard> <Storyboard > 
                                            <DoubleAnimation   AutoReverse="True" Duration="0:0:1"
                                         From
    ="1.0" RepeatBehavior="Forever"  Storyboard.TargetName="txt" Storyboard.TargetProperty="Opacity"   To="0.0"/>  
                                        </Storyboard> 
                                        </BeginStoryboard>                             
                                    </EventTrigger>                        
                                </TextBlock.Triggers>
                        </TextBlock>
                    </StackPanel>
                </Border>
            </Popup>
            <!--ContentPanel - 在此处放置其他内容-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <Image Height="246" HorizontalAlignment="Left" Margin="101,182,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="197" DataContext="{Binding}" Source="/PhoneApp1;component/Images/7.jpg" />
            </Grid>
        </Grid>

    public partial class MainPage : PhoneApplicationPage
        {
            Storyboard _timer = new Storyboard();

            Storyboard story;


            int i = 0;
            // 构造函数
            public MainPage()
            {
                InitializeComponent();
                _timer.Duration = TimeSpan.FromMilliseconds(10);
                _timer.Completed += new EventHandler(_timer_Completed);
                _timer.Begin();
                i = Convert.ToInt32(txt.Text);
            }
            void _timer_Completed(object sender, EventArgs e)
            {

                if (i <= txt.MaxHeight)
                {
                    i++;
                    this.txt.Text = i.ToString();
                    _timer.Begin();

                    return;
                }

                this.Dispatcher.BeginInvoke(new Action(() => { ProgressPopup.IsOpen = false; }));
            }

            private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
            {
                //ProgressPopup.IsOpen = true;
               
    // this.Dispatcher.BeginInvoke(new Action(() => ProgressPopup.IsOpen = true));
                story = PrepareShowStory();
                story.Begin();
            }

            private Storyboard PrepareShowStory()
            {
                Storyboard story = new Storyboard();
                DoubleAnimation animation;

                animation = new DoubleAnimation();
                animation.From = 0;
                animation.To = 100;
                animation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
                Storyboard.SetTarget(animation, image1);
                //Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)"));
                Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Height)"));
                story.Children.Add(animation);

                story.AutoReverse = true;
                story.RepeatBehavior = new RepeatBehavior(3); //RepeatBehavior.Forever;

                return story;
            }
        }
  • 相关阅读:
    Axure案例:用中继器实现便捷好用的3级菜单--转载
    我说CMMI之七:需求管理过程域--转载
    我说CMMI之六:CMMI的评估--转载
    我说CMMI之五:CMMI 4个等级的区别--转载
    我说CMMI之四:CMMI的表示方法--转载
    我说CMMI之三:CMMI的构件--转载
    我说CMMI之二:CMMI里有什么?--转载
    我说CMMI之一:CMMI是什么--转载
    PMBOK :美国的项目管理知识体系
    有关 CMMI
  • 原文地址:https://www.cnblogs.com/zziss/p/2766522.html
Copyright © 2020-2023  润新知