I am using animations with my window to slide out or slide back up.
But when these animations are not used.
I would like to use Window.Top to set the position of the window,
but I think due to animations I cannot set the top.
I was wondering if anyone knows how to fix this? Thanks
example.
window.top is already = 33.
but when is ay
window.top =900;
it will stay at 33.
Manual value changes are ignored while an animation is running. You need to remove the animation from the property entirely to make the manually-set values visible.
If you started your animation with a BeginStoryboard action, use a RemoveStoryboard action to remove it:
<RemoveStoryboard BeginStoryboardName="NameOfStoryboard" />
If you applied your animation in code or otherwise, the trick is to pass "null" into the BeginAnimation method to remove it:
window.BeginAnimation(Window.TopProperty, null);
In many cases you can call a Storyboard's Remove method to reset the value source from an animation back to the original source, in this case your explicit value. If you could post some code it would be easier to get a more definitive answer.
Try setting FillBehavior="Stop" in your animation.
Related
Ok so, I did this:
print(Anim.GetCurrentAnimatorStateInfo(0).shortNameHash);
When I play an animation like so
Anim.Play("AnimationName");
The value printed changes and then stays the same and doesn't change back to the default animation.
I also tried with the following:
if (Anim.GetCurrentAnimatorStateInfo(0).IsName("FireAnimation"))
I want to be able to get a constant update on the current animation that is playing. If you have any method that doesn't involve using a clock please do help.
I realized the best way to do this is to use the animation controller and change varialbes using SetBool(); and SetFloat(); etc.
I have a SpriteVisual for which I'm animating opacity, offset, and size using KeyFrameAnimations. While the animation is running the property values seem to be unaffected: they show the initial values until the animation finishes, at which point they update to the final values.
I would like to be able to get the current value part-way through the animation without having to either stop the animation to synchronise the properties or to store a separate copy of the animation and the time it started in order to calculate the value myself.
Is this possible?
As far as I known, it is impossible.
When we use the StartAnimation method of the SpriteVisual class to add the KeyFrameAnimation to it and start the animation, that there is no method to get the current value.
We can use the KeyFrameAnimation and the SpriteVisual to change the value of the property during the animation.There is an ForegroundFocusEffects sample that you can refer it, it uses the ScalarKeyFrameAnimation and set the Duration of the animation.
So im developing this app, where i got something that reminds alot about a list, but it doesn't use a list control or something. I add grids & rectangels to a scrollviewer, and when i doubletap a grip or a rectangel, it dissapears with a fade animation (which i also need help to do, as well as fade in, fast, one by one on app startup), and when that happens, i want the grid or rectangel beneath the one that faded out (or was removed, what is the best solution?), to be slided up, and replace the empty position. Please, do not misunderstand the question, i dont want you to make it for me, i want to know how since i absolutely cannot find ANY solution at all. It kind of works like google now for android and iphone. How can i do this the best way? Thank you SO much! Best regards, Erik
My DoubleAnimation to fade the grid:
DoubleAnimation fadeGrid = new DoubleAnimation();
fadeGrid.From = 0;
fadeGrid.To = 1;
fadeGrid.Duration = new Duration(TimeSpan.FromSeconds(0.5));
fadeGrid.AutoReverse = false;
1) Use animations for your fade out and slide up. For fade, you'll be doing a DoubleAnimation on the Opacity property. For sliding items up, you'll be doing an animiation on the TranslateTransform property. See these MSDN guides: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206955(v=vs.105).aspx and http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.media.translatetransform(v=vs.105).aspx
2) For actually properly moving things up, you'll want to capture the Completed event from the animiation (http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.media.animation.timeline.completed(v=vs.105).aspx). When the animiation completes, remove those controls from the StackPanel inside the ScrollViewer, and undo any position animation you did on the items below it to animate them 'sliding' up.
3) After creating an animiation, you need to add it to a storyboard:
Storyboard sb = new Storyboard();
sb.Children.Add(fadeGrid);
Storyboard.SetTarget(fadeGrid, myRectangle);
Storyboard.SetTargetProperty(fadeGrid, new PropertyPath("(UIElement.Opacity)"));
sb.Begin();
The syntax for the propertypath but not be quite perfect, but you get the idea. You can see another example that specifically mentions opacity here: http://blogs.msdn.com/b/silverlight_sdk/archive/2008/03/21/silverlight-animations-a-walkthrough.aspx
I'm trying to create an animation similar to the AppBar - basically make a control come in from the bottom edge of the screen. The problem with this is that the height of the control can change depending on its content, so I can't set an initial TranslateTransform.Y value in the XAML or in the Loaded event because the contents get generated AFTER the page is loaded.
So, in other (and fewer) words. I need to animate a control for which I don't know its size into the screen. Any ideas?
Thanks in advance.
You can use a Transition.
E.g. PaneThemeTransition or EntranceThemeTransition.
I'm not sure which property you should use to add a transition because it depends on your case. But you can do something like this:
Popup.ChildTransitions = new TransitionCollection { new EntranceThemeTransition() };
The Popup is not mandatory:
<uielement>
<uielement.Transitions>
oneOrMoreTransitions
</uielement.Transitions>
</uielement>
Animations
I have something like this:
barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation(
barProgress.Value, dNextProgressValue,
new Duration(TimeSpan.FromSeconds(dDuration)));
Now, how would you stop that animation (the DoubleAnimation)? The reason I want to do this, is because I would like to start new animations (this seems to work, but it's hard to tell) and eventually stop the last animation...
To stop it, call BeginAnimation again with the second argument set to null.
When using storyboards to control an animation, make sure you set the second parameter to true in order to set the animation as controllable:
public void Begin(
FrameworkContentElement containingObject,
**bool isControllable**
)
There are two ways to stop a BeginAnimation. The first is to call BeginAnimation again with the second parameter set to null. This will remove all animations on the property and revert the value back to its base value.
Depending on how you are using that value this may not be the behavior you want. The second way is to set the animations BeginTime to null then call BeginAnimation with it. This will remove that specific animation and leave the value at its current position.
DoubleAnimation myAnimation = new Animation();
// Initialize animation
...
// To start
element.BeginAnimation(Property, myAnimation);
// To stop and keep the current value of the animated property
myAnimation.BeginTime = null;
element.BeginAnimation(Property, myAnimation);
<Trigger.EnterActions>
<BeginStoryboard x:Name="myStory">
.........
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="myStory"/>
</Trigger.ExitActions>
In my case I had to use two commands, my xaml has a button which fires a trigger, and its trigger fires the storyboard animation.
I've put a button to stop animation with this code behind:
MyBeginStoryboard.Storyboard.Begin(this, true);
MyBeginStoryboard.Storyboard.Stop(this);
I don't like it but it really works here. Give it a try!
If you want the base value to become
the effective value again, you must
stop the animation from influencing
the property. There are three ways to
do this with storyboard animations:
Set the animation's FillBehavior
property to Stop
Remove the entire Storyboard
Remove the animation from the
individual property
From MSDN
How to: Set a Property After Animating It with a Storyboard
Place the animation in a StoryBoard. Call Begin() and Stop() on the storyboard to start to stop the animations.
You can use this code:
[StoryBoardName].Remove([StoryBoardOwnerControl]);