How do I get an animated gif to work in WPF?

前端 未结 18 1165
广开言路
广开言路 2020-11-22 12:16

What control type should I use - Image, MediaElement, etc.?

18条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 12:26

    I had this issue, until I discovered that in WPF4, you can simulate your own keyframe image animations. First, split your animation into a series of images, title them something like "Image1.gif", "Image2,gif", and so on. Import those images into your solution resources. I'm assuming you put them in the default resource location for images.

    You are going to use the Image control. Use the following XAML code. I've removed the non-essentials.

    
       
          
                
                   
                       
                          
                             
                                
                             
                          
                         
                            
                               
                            
                         
                         
                            
                               
                            
                         
                         
                            
                               
                            
                         
                         
                            
                               
                            
                         
                      
                   
                
             
          
       
    
    

提交回复
热议问题