本文整理汇总了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);
};
}