当前位置: 首页>>代码示例>>C#>>正文


C# TextBlock.RegisterName方法代码示例

本文整理汇总了C#中System.Windows.Controls.TextBlock.RegisterName方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.RegisterName方法的具体用法?C# TextBlock.RegisterName怎么用?C# TextBlock.RegisterName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.TextBlock的用法示例。


在下文中一共展示了TextBlock.RegisterName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopupMsg

        public PopupMsg(TextBlock msg)
        {
            //Store TextBlock for message display
            this.msg = msg;
            //Register the textblock's name, this is necessary for creating Storyboard using codes instead of XAML
            NameScope.SetNameScope(msg, new NameScope());
            msg.RegisterName("fadetext", msg);

            //Create the fade in & fade out animation
            DoubleAnimationUsingKeyFrames fadeInOutAni = new DoubleAnimationUsingKeyFrames();
            LinearDoubleKeyFrame keyframe = new LinearDoubleKeyFrame();
            keyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2));
            keyframe.Value = 1;
            fadeInOutAni.KeyFrames.Add(keyframe);
            //keyframe = new LinearDoubleKeyFrame();

            fadeInOutAni.Duration = new Duration(TimeSpan.FromSeconds(4));        
            fadeInOutAni.AutoReverse = true;
            fadeInOutAni.AccelerationRatio = .2;
            fadeInOutAni.DecelerationRatio = .7;

            // Configure the animation to target the message's opacity property
            Storyboard.SetTargetName(fadeInOutAni, "fadetext");
            Storyboard.SetTargetProperty(fadeInOutAni, new PropertyPath(TextBlock.OpacityProperty));

            // Add the fade in & fade out animation to the Storyboard
            Storyboard fadeInOutStoryBoard = new Storyboard();
            fadeInOutStoryBoard.Children.Add(fadeInOutAni);

            // Set event trigger, make this animation played on an event we can control
            msg.IsVisibleChanged += delegate(object sender,  System.Windows.DependencyPropertyChangedEventArgs e)
            {
                if (msg.IsVisible) fadeInOutStoryBoard.Begin(msg);
            };
        }
开发者ID:bartonnen,项目名称:MediaBrowser.Classic,代码行数:35,代码来源:PopupMsg.cs


注:本文中的System.Windows.Controls.TextBlock.RegisterName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。