Quantcast
Channel: User Sinatr - Stack Overflow
Viewing all articles
Browse latest Browse all 609

Answer by Sinatr for How do I make a smooth transition in the slider switch?

$
0
0

I am not sure if using multiple storyboards with FillBehavior=Stop nor the layout is the best, but anyway to fix your code, you may need to cancel other storyboard.

Give names to storyboards and use StopStoryBoard or (preferably) RemoveStoryBoard:

<Trigger.EnterActions><BeginStoryboard x:Name="checked" ><Storyboard><DoubleAnimation Storyboard.TargetName="EllipseTranslateTransform" Storyboard.TargetProperty="X" To="10" Duration="0:0:0.2" /></Storyboard></BeginStoryboard><StopStoryboard BeginStoryboardName="unchecked" /></Trigger.EnterActions><Trigger.EnterActions><BeginStoryboard x:Name="unchecked"><Storyboard><DoubleAnimation Storyboard.TargetName="EllipseTranslateTransform" Storyboard.TargetProperty="X" From="10" Duration="0:0:0.2" /></Storyboard></BeginStoryboard><StopStoryboard BeginStoryboardName="checked" /></Trigger.EnterActions>

Also note, that default value TranslateTransform.X=0, so you don't need to specify From or To when going from/to 0 (as you already did in first animation), rather only specify non-default value.

Edit: The value X=10 seems more approparite than 25, edited in snippet.

I put the ToggleButton into Viewbox to observe smooth animation:

enter image description here


Viewing all articles
Browse latest Browse all 609

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>