문제
.NET 코드에서 스토리 보드를 중지하고 다시 시작하는 올바른 방법은 무엇입니까?
노력하고있어 ...
myStory.Stop(this);
.Begin (this)에 대한 후속 호출을 기대합니다. 타임 라인에서 Zero에서 다시 시작되지만 대신 스토리 보드가 중지 된 곳에서 바로 픽업됩니다.
나는 시도했다
.Remove(this);
그리고 나는 시도했다
.Seek(TimeSpan.Zero);
또한 작동하지 않았습니다.
자세한 내용은 ... 여기 내 스토리 보드 샘플이 있습니다.
<Storyboard x:Key="overlay">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textone" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="texttwo" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
따라서 Textone의 텍스트가 실행되고 화면을 닫고 화면으로 빠르게 돌아 오면 TextTwo는 실제로 새로 시작된 스토리 보드 위로 재생됩니다. 그래서 첫 번째 화면에서 오리지널 스토리 보드는 내가 제거하고 중지했지만 여전히 주위에 놀고 있습니다.
해결책
Storyboard.seek (timespan.zero)를 사용하는 것은 어떻습니까? 스트림을 찾는 것과 마찬가지로, 이것은 애니메이션의 시작 부분으로 되돌아 갈 것입니다.
나는 또한 당신이 istontrollable 속성이 True로 설정되어 있는지 확인해야한다고 언급했습니다. 명심하십시오!
다른 팁
Mystory.begin (this)을 처음부터 시작하기 전에 Mystory.remove (this)를해야합니다. 스토리 보드를 호출하는 것은 정지가 애니메이션 시계를 멈추지 만 그대로 남겨두기 때문입니다. 이후에 시작하려는 전화는 단순히 이력서 역할을합니다. 나는 이것이 다소 반 직관적이라는 데 동의하지만, 문서를 읽으면 ClockController :: 중지, 당신은 다음과 같이 다음을 볼 수 있습니다.
이 방법은 대상 클럭의 현재 상태를 중지하도록 변경합니다.
시작, SEEK 또는 SEEKALIGNEDTOLASTTICK 메소드를 사용하여 정지 시계를 다시 시작할 수 있습니다.
Scott 죄송합니다.주의를 기울이지 않았습니다. 스토리 보드에서 FillBehavior를 설정하려고 했습니까? FillBehavior를 설정하여 애니메이션을 재설정하십시오. 왜 멈추지 않는지 확실하지 않습니다. 그래도 ...
<Storyboard x:Key="overlay">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textone" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="texttwo" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
using System.Windows.Media.Animation;
그런 다음 새 스토리 보드를 만듭니다
Storyboard storyboard_name = (Storyboard)(FindResource("overlay"));
storyboard_name.Begin();
스토리 보드 "Storyboard_name"이 시작됩니다.
스토리 보드를 멈추고 싶다면 이렇게 시도해보십시오.
storyboard_name.Stop();
스토리 보드를 제거하려면 이렇게 시도해보십시오.
storyboard_name.Remove();
다른 세부 사항은 다음과 같습니다.
this.myAnimation.fillBehavior = fillBehavior.stop;