2017-09-27 9 views
0

버튼 클릭시 스트레치/슬라이드 오버하도록 설정 한 메인 페이지 내에 프레임이 있습니다. 첫 번째 버튼 클릭에서 프레임을 늘리거나/슬라이드하지 않고 오히려 동일한 버튼을 두 번째 클릭 할 때 사용합니다. XAML : I 버튼 내 VB.net 코드에서 storyboard.stop()/storyboard.being()를 사용하여 시도해 봤지만 XAML처럼 보인다버튼을 트리거 할 애니메이션 설정 첫 번째 클릭이 아닌 두 번째 클릭

 <Storyboard x:Key="FrameSlide"> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="currentPage"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="1"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:0.7" Value="1.217"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="currentPage"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="0"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:0.7" Value="-126"/> 
     </DoubleAnimationUsingKeyFrames> 
    </Storyboard> 
    <Storyboard x:Key="FrameSlideBack"> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="currentPage"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="1.217"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:0.7" Value="1"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="currentPage"> 
      <SplineDoubleKeyFrame KeyTime="0" Value="-126"/> 
      <SplineDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
    </Storyboard> 




</Window.Resources> 
<Window.Triggers> 
    <EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown" SourceName="TransmitBTN"> 
     <BeginStoryboard x:Name="FrameSlide" Storyboard="{StaticResource FrameSlide}"/> 
    </EventTrigger> 
    <EventTrigger RoutedEvent="UIElement.MouseLeftButtonDown" SourceName="PatientBTN"> 
     <BeginStoryboard x:Name="FrameSlideBack" Storyboard="{StaticResource FrameSlideBack}"/> 
    </EventTrigger> 
</Window.Triggers> 

은 VB 코드를 면하게 이상이다. 내 프레임이 특정 너비 인 문장을 if 피곤하게 한 다음 애니메이션을 트리거하는 다른 작업을 수행하지 않습니다. 여기에서 어디로 가는지 잘 모르겠습니다. 감사합니다

답변

0

저는 VB에서 알지 못하기 때문에이 질문에 답하고 있습니다.하지만 당신이 쉽게 바꿀 수 있다고 들었습니다.

나는 우리와 함께 할 수있는 대답은 버튼 안에서 이벤트를 만든다. 클래스 내의 button_click은 public 속성을 만든다. 이벤트가 증가 할 때 속성을 증가시키고 2에 도달하면 이야기 게시판을 시작합니다. 버튼 이벤트

XAML :

<Button x:Name="button" Content="Button" Click="Button_OnClick" 

C# 코드 :

public partial class StackOverFlowExample 
{ 
    public StackOverFlowExample() 
    { 
    InitializaComponent(); 
    buttonClickCounter = 0; 
    } 

    public int buttonClickCounter {get; set;} 

    private void Button_Click(object sender, RoutedEventArgs e) 
    { 
    buttonClickCounter++; 
    if (buttonClickCounter == 2) 
    { 
     buttonClickCounter = 0; 

     Storyboard sb = Application.Current.Resources["FrameSlide"] as 
     Storyboard; 

     if (sb.IsSealed) 
      sb = sb.Clone(); 
     Storyboard.SetTarget(sb, this.NextButton); 
     sb.Completed += delegate { }; 
     sb.Begin(); 
    } 

    e.Handled = true; 
    } 
} 
+0

덕분에,이 올바른 방향으로 절 지적했다. 나는 그것을 작동 시켰어. – Elliott

+0

@ 엘리엇 문제 없음 : p 만족 스럽다면 답변을 수락하십시오! :피 – JohnChris