2017-02-24 18 views
1

我對WPF很陌生,嘗試使用情節串連圖板的某些內容,我想要的是在第一次看到情節串連圖板時開始。它是在一個嚮導的工序不是在負載可見)帶有圖像的WPF情節串連圖板,當它可見時啓動棋盤

<Grid Name="GridLoading" Visibility="Hidden" > 

     <Image> 
      <Image.Triggers> 
       <EventTrigger RoutedEvent="Loaded"> 

        <BeginStoryboard > 
         <Storyboard Name="LoadingStoryBoard" Completed="LoadingStoryBoard_Completed"> 
          <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Source" 
               Duration="0:0:4"> 
           <DiscreteObjectKeyFrame KeyTime="0:0:0"> 
            <DiscreteObjectKeyFrame.Value> 
             <BitmapImage UriSource="C:\...\2a-loading.jpg"/> 
            </DiscreteObjectKeyFrame.Value> 
           </DiscreteObjectKeyFrame> 
           <DiscreteObjectKeyFrame KeyTime="0:0:1"> 
            <DiscreteObjectKeyFrame.Value> 
             <BitmapImage UriSource="C:\...\2b-loading.jpg"/> 
            </DiscreteObjectKeyFrame.Value> 
           </DiscreteObjectKeyFrame> 
           <DiscreteObjectKeyFrame KeyTime="0:0:2"> 
            <DiscreteObjectKeyFrame.Value> 
             <BitmapImage UriSource="C:\...\2c-loading.jpg"/> 
            </DiscreteObjectKeyFrame.Value> 
           </DiscreteObjectKeyFrame> 
           <DiscreteObjectKeyFrame KeyTime="0:0:3"> 
            <DiscreteObjectKeyFrame.Value> 
             <BitmapImage UriSource="C:\...\2d-loading.jpg"/> 
            </DiscreteObjectKeyFrame.Value> 
           </DiscreteObjectKeyFrame> 
          </ObjectAnimationUsingKeyFrames> 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
      </Image.Triggers> 
     </Image> 

    </Grid> 

任何指針不勝感激

回答

1

這是一個重複的:在該問題從accepted answer兩者Activate Storyboard on Visibility Changed

<Style x:Key="AnimationImageStyle" TargetType="{x:Type Image}"> 
<Style.Triggers> 
    <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=IsVisible}" 
       Value="True"> 

     <DataTrigger.EnterActions> 
      <BeginStoryboard> 
       <Storyboard> 
        <DoubleAnimation Storyboard.TargetProperty="Opacity" 
            From="1.0" To="0.1" 
            Duration="0:0:0.5" 
            AutoReverse="True" 
            RepeatBehavior="0:0:2" /> 
       </Storyboard> 
      </BeginStoryboard> 
     </DataTrigger.EnterActions> 
    </DataTrigger> 
</Style.Triggers> 

與你的故事板更換內部<DataTrigger.EnterActions>故事板。

問題更有經驗的用戶:如何將帖子標記爲重複?或者是僅用於mods?

+0

謝謝!我現在唯一需要弄清楚的是在動畫完成時執行一些代碼,因爲如果Completed =「LoadingStoryBoard_Completed」在樣式元素中,它似乎是無效的 –