I am using this code for gif Animating in seprate library and xaml code in my main project:
Try this:
BTW, I found using this way to play gif in wpf might deform some gif images, and I wonder why...