如何讓一個動畫的.gif動畫化WPF用戶控件中的每一幀?這裏的.gif只顯示第一幀。動畫GIF不在WPF中動畫
<UserControl.Triggers>
<EventTrigger RoutedEvent="Button.Click" SourceName="btnPressQ">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource sbdShowAlfa}"/>
</EventTrigger.Actions>
</EventTrigger>
</UserControl.Triggers>
<Button Grid.Column="2" Command="{Binding Path=PressAndRelease}" CommandParameter="Q" Style="{StaticResource TransparentButton}">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Image Name="imgNormalQ" Source="/Wosk;component/Images/Alphaberts/Q1.png" Height="127" />
<Image Name="imgPressedQ" Source="/Wosk;component/Images/Alphaberts/DancingPeaks.gif" Height="262" Width="119" Margin="-23,-136,-21,0" Visibility="Hidden"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Panel.ZIndex" Value="999"/>
<Setter TargetName="imgPressedQ" Property="Visibility" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
本地WPF不支持GIF,你需要自定義類[獲取GIF在WPF玩(與GifImage類)] [1] [1]:http://stackoverflow.com/questions/5566330/get-gif-to-play-in-wpf-with-gifimage-class – aifarfa 2012-04-09 03:30:36
Thx @ ai.farfa。我會嘗試。 – hakunabean 2012-04-09 03:37:13
請檢查這個鏈接,http://stackoverflow.com/questions/10764585/how-to-add-gif-image-to-wpf – 2012-06-01 00:58:30