2015-07-13 172 views
0

我試圖在點擊一個按鈕後做出矩形動畫。wpf按鈕故事板觸發器

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 

<Button Content="FirstButton" HorizontalAlignment="Left" Height="60" Margin="341,91,0,0" VerticalAlignment="Top" Width="91"> 
     <i:Interaction.Triggers> 
      <i:EventTrigger EventName="Click"> 
       ??? <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/> 
      </i:EventTrigger> 
     </i:Interaction.Triggers> 
    </Button> 

我需要寫什麼?

+0

我相信你需要把'BeginStoryboard'元素放在一個'i:EventTrigger.EnterActions'元素中。 –

回答

0
<StackPanel> 
    <Button Name="Button"/> 
    <Rectangle> 
     <Rectangle.Style> 
      <Style TargetType="Rectangle"> 
       <Style.Triggers> 
        <DataTrigger Binding="{Binding ElementName=Button, Path=IsPressed}" Value="True"> 
         <DataTrigger.EnterActions> 
          <BeginStoryboard> 
           <Storyboard> 

           </Storyboard> 
          </BeginStoryboard> 
         </DataTrigger.EnterActions> 
        </DataTrigger> 
       </Style.Triggers> 
      </Style> 
     </Rectangle.Style> 
    </Rectangle> 
</StackPanel>