2011-11-07 3 views
1

나는 앞뒤로 불투명도를 애니메이트하는 구성 요소를 가지고 있습니다.사용자 콘트롤의 애니메이션

어떻게 애니메이션을 바로 실행합니까?

여기에 해당 애니메이션에 대한 내 리소스가 있습니까? 이것은 작동 할 수

<RadioButton.Resources> 
    <Style x:Key="PhoneRadioButtonCheckBoxBase" TargetType="ToggleButton"> 
     <Setter Property="Background" Value="{StaticResource PhoneRadioCheckBoxBrush}"/> 
     <Setter Property="BorderBrush" Value="{StaticResource PhoneRadioCheckBoxBrush}"/> 
     <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/> 
     <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/> 
     <Setter Property="HorizontalContentAlignment" Value="Left"/> 
     <Setter Property="VerticalContentAlignment" Value="Center"/> 
     <Setter Property="Padding" Value="1"/> 
    </Style> 
    <Style x:Key="RectToggleButton" TargetType="RadioButton"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="RadioButton"> 
        <Grid x:Name="grid" Background="Transparent" Loaded="grid_Loaded"> 
         <Grid.Resources> 
          <Storyboard x:Name="Strobing" AutoReverse="True" RepeatBehavior="Forever"> 
           <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HighlightedSprite"> 
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.495"/> 
            <EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/> 
           </DoubleAnimationUsingKeyFrames> 
          </Storyboard> 
         </Grid.Resources> 
+1

당신이 "바로 애니메이션을 실행"무슨 뜻인지 확실하지. 컨트롤이 인스턴스화되는 즉시 애니메이션을 실행하는 것을 의미합니까? – danbord

+0

그래, 그게 내가 원하는거야 –

답변

1

: -

    <Grid x:Name="grid" Background="Transparent" > 
         <Grid.Triggers> 
           <EventTrigger RoutedEvent="RadioButton.Loaded"> 
            <BeginStoryboard> 
          <Storyboard AutoReverse="True" RepeatBehavior="Forever"> 
           <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HighlightedSprite"> 
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.495"/> 
            <EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/> 
           </DoubleAnimationUsingKeyFrames> 
          </Storyboard> 
            </BeginStoryboard> 
           </EventTrigger> 
         </Grid.Triggers> 

또는 당신이 시도 할 수 : -

   <ControlTemplate TargetType="RadioButton"> 
        <Grid x:Name="grid" Background="Transparent"> 
         <VisualStateManger.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"> 
          <Storyboard AutoReverse="True" RepeatBehavior="Forever"> 
           <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HighlightedSprite"> 
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.495"/> 
            <EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/> 
           </DoubleAnimationUsingKeyFrames> 
          </Storyboard> 
           </VisualState> 
         </VisualStateGroup> 
         </VisualStateManger.VisualStateGroups> 
+0

WP7에서 트리거가 없습니다 –

+0

@Joseph : Silverlight에는 일반 트리거가 없지만로드 된 이벤트는 특별한 경우로 취급됩니다. 지금까지 내가 워드 프로세서에서 볼 수있는이 특별한 사용법은 WP7 – AnthonyWJones

+0

에서 지원합니다. 스토리 보드를 사용하지 않고 단추의 기본/비활성 상태를 사용하고 전환을 마우스 오른쪽 단추로 클릭하고 반복을 선택하고 영원히 클릭하면 해결됩니다. –

관련 문제