2016-09-27 65 views
0

我想在动画完成时将我的数据绑定属性IsFlashing设置为False当动画在WPF中完成时,取消设置数据绑定属性

<Border BorderThickness="1" 
        Height="15" 
        Width="20" 
        CornerRadius="2" 
        BorderBrush="Black" 
        DockPanel.Dock="Top" 
        Grid.Row="1" > 

     <Border.Style> 
      <Style> 
       <Style.Triggers> 
        <DataTrigger Binding="{Binding IsFlashing}" Value="True" x:Name="dataTrigger"> 
         <DataTrigger.EnterActions> 
          <BeginStoryboard> 
           <Storyboard FillBehavior="Stop" RepeatBehavior="1x" x:Name="startStoryBoard">           
            <ObjectAnimationUsingKeyFrames 
              Storyboard.TargetProperty="Background" 
              Duration="0:0:4" RepeatBehavior="1x">  
             <ObjectAnimationUsingKeyFrames.KeyFrames>  
              <DiscreteObjectKeyFrame KeyTime="0:0:1"> 
               <DiscreteObjectKeyFrame.Value> 
                <LinearGradientBrush> 
                 <LinearGradientBrush.GradientStops> 
                  <GradientStop Color="Yellow" Offset="0.0" /> 
                  <GradientStop Color="Orange" Offset="0.9" /> 
                  <GradientStop Color="Red" Offset="1.0" /> 
                 </LinearGradientBrush.GradientStops> 
                </LinearGradientBrush> 
               </DiscreteObjectKeyFrame.Value> 
              </DiscreteObjectKeyFrame> 
             </ObjectAnimationUsingKeyFrames.KeyFrames> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </BeginStoryboard> 
         </DataTrigger.EnterActions> 
         <DataTrigger.ExitActions>  
          <!-- how can I set my bound property "IsFlashing" to false when we exit here ? --> 
         </DataTrigger.ExitActions> 
        </DataTrigger> 
       </Style.Triggers> 
      </Style> 
     </Border.Style> 
     <Border.Background> 
      <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> 
       <GradientStop Color="#FFFFFF" Offset="0.0" /> 
       <GradientStop Color="#ADD8E6" Offset="0.9" /> 
       <GradientStop Color="#8aacb8" Offset="1.0" /> 
      </LinearGradientBrush> 
     </Border.Background> 
     <TextBlock Foreground="Black" Text="{Binding Path=MarkerCode}" FontFamily="Segoe UI" FontSize="12" TextAlignment="Center" VerticalAlignment="Center"> 
      <TextBlock.Effect> 
       <DropShadowEffect ShadowDepth="0" BlurRadius="3" Color="White" /> 
      </TextBlock.Effect> 
     </TextBlock> 

</Border> 

回答

1

Completed事件ObjectAnimationUsingKeyFrames

ExitActions的是当触发条件不再满足(在这种情况下IsFlashing返回到假时)会发生什么,这是不一样的动画完成。

+0

完成的事件只适用于故事板是静态的,然后事件触发,但我无法从我的DataContext类型的发件人AnimationClock – 0x4f3759df

+0

我提出了一个新的问题,http://stackoverflow.com/questions/39750114/setting-一个属性上,WPF的动画出口22条军规 – 0x4f3759df