本文整理汇总了C#中System.Windows.FrameworkElement.BeginStoryboard方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.BeginStoryboard方法的具体用法?C# FrameworkElement.BeginStoryboard怎么用?C# FrameworkElement.BeginStoryboard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.BeginStoryboard方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunScaleAnimation
public static void RunScaleAnimation(FrameworkElement e)
{
var storyboard = new Storyboard();
var easeOut = new BackEase { EasingMode = EasingMode.EaseOut, Amplitude = 0.3 };
var startHeight = e.ActualHeight;
var startWidth = e.ActualWidth;
var growAnimationHOut = new DoubleAnimation(startHeight, startHeight * 1.05,
TimeSpan.FromMilliseconds(70)) { AutoReverse = true };
var growAnimationWOut = new DoubleAnimation(startWidth, startWidth * 1.05,
TimeSpan.FromMilliseconds(70)) { AutoReverse = true };
growAnimationHOut.EasingFunction = easeOut;
growAnimationWOut.EasingFunction = easeOut;
storyboard.Children.Add(growAnimationHOut);
storyboard.Children.Add(growAnimationWOut);
//remove the events after completed to ensure that the ScatterViewItem is resizable again
growAnimationWOut.Completed += delegate { e.BeginAnimation(FrameworkElement.WidthProperty, null); };
growAnimationHOut.Completed += delegate { e.BeginAnimation(FrameworkElement.HeightProperty, null); };
Storyboard.SetTargetProperty(growAnimationWOut, new PropertyPath(FrameworkElement.WidthProperty));
Storyboard.SetTargetProperty(growAnimationHOut, new PropertyPath(FrameworkElement.HeightProperty));
e.BeginStoryboard(storyboard);
}
示例2: TranslateItem
private static void TranslateItem(FrameworkElement f, double yDelta, int milliseconds)
{
Storyboard sb = (Storyboard)f.GetValue(s_dragPreviewStoryboardProperty);
SplineDoubleKeyFrame k;
if (sb == null) {
TranslateTransform t;
DoubleAnimationUsingKeyFrames d;
t = new TranslateTransform();
f.RenderTransform = t;
sb = new Storyboard();
k = new SplineDoubleKeyFrame();
k.KeySpline = new KeySpline(0, 0.7, 0.7, 1);
d = new DoubleAnimationUsingKeyFrames();
d.KeyFrames.Add(k);
Storyboard.SetTarget(d, f);
Storyboard.SetTargetProperty(d, new PropertyPath("(RenderTransform).(TranslateTransform.Y)"));
sb.Children.Add(d);
f.SetValue(s_dragPreviewStoryboardProperty, sb);
}
else {
k = (sb.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as SplineDoubleKeyFrame;
}
k.Value = yDelta;
k.KeyTime = TimeSpan.FromMilliseconds(milliseconds);
f.BeginStoryboard(sb);
}
示例3: translate
private void translate(FrameworkElement element, double from, double to)
{
DoubleAnimation da = new DoubleAnimation( from, to, new Duration(TimeSpan.FromMilliseconds(500)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)")); //Do not miss the '(' and ')'
sb.Children.Add(da);
element.BeginStoryboard(sb);
}
示例4: TranslateAnimation
void TranslateAnimation(FrameworkElement fe, double offset, bool vertical=false)
{
var translated = fe.RenderTransform as TranslateTransform;
if (!fe.RenderTransform.HasAnimatedProperties)
{
var translate = new TranslateTransform();
fe.RenderTransform = translate;
}
var storyboard = new Storyboard();
var animation = new DoubleAnimation();
/*
if (offset == 0)
{
// animation.From = translated.X;
}
*/
animation.To = offset;
animation.Duration = new Duration(TimeSpan.FromSeconds(1));
var ease = new BackEase();
ease.EasingMode = EasingMode.EaseInOut;
ease.Amplitude = 1;
animation.EasingFunction = ease;
PropertyPath path;
if (vertical)
{
path = new PropertyPath("(RenderTransform).(TranslateTransform.Y)");
}
else
{
path = new PropertyPath("(RenderTransform).(TranslateTransform.X)");
}
Storyboard.SetTargetProperty(animation, path);
storyboard.Children.Add(animation);
fe.BeginStoryboard(storyboard);
}
示例5: TranslateItem
private static void TranslateItem(FrameworkElement element, double delta, int milliseconds, Orientation orientation)
{
var storyboard = (Storyboard)element.GetValue(s_dragPreviewStoryboardProperty);
SplineDoubleKeyFrame keyframe;
if (storyboard == null)
{
var t = new TranslateTransform();
element.RenderTransform = t;
keyframe = new SplineDoubleKeyFrame
{
KeySpline = new KeySpline(0, 0.7, 0.7, 1)
};
var animation = new DoubleAnimationUsingKeyFrames();
animation.KeyFrames.Add(keyframe);
Storyboard.SetTarget(animation, element);
PropertyPath propertyPath;
if (orientation == Orientation.Vertical)
{
propertyPath = new PropertyPath("(RenderTransform).(TranslateTransform.Y)");
}
else
{
propertyPath = new PropertyPath("(RenderTransform).(TranslateTransform.X)");
}
Storyboard.SetTargetProperty(animation, propertyPath);
storyboard = new Storyboard();
storyboard.Children.Add(animation);
element.SetValue(s_dragPreviewStoryboardProperty, storyboard);
}
else
{
keyframe = storyboard.Children.Cast<DoubleAnimationUsingKeyFrames>().Single().KeyFrames.Cast<SplineDoubleKeyFrame>().Single();
}
keyframe.Value = delta;
keyframe.KeyTime = TimeSpan.FromMilliseconds(milliseconds);
element.BeginStoryboard(storyboard);
}