我正在尝试使用https://github.com/XamlAnimatedGif/WpfAnimatedGif/中的库来使用 wpf 解决我的动画 gif。我编写了一些代码将图像绑定到图像,但它不起作用。
WPF:
<Image gif:ImageBehavior.RepeatBehavior="Forever"
gif:ImageBehavior.AnimatedSource="{Binding ElementName=WpfAnimation, Path=ImageStatus}"/>
代码背后:
// Image status property
public readonly DependencyProperty ImageStatusProperty;
public ImageSource ImageStatus
{
get { return (ImageSource)GetValue(ImageStatusProperty); }
set { SetValue(ImageStatusProperty, value); }
}
public MainWindow()
{
InitializeComponent();
ImageStatus = new BitmapImage(new Uri("Images/anipier_e0.gif", UriKind.Relative));
}
错误:
System.Windows.Markup.XamlParseException was unhandled
HResult=-2146233087
Message='The invocation of the constructor on type 'WpfAnimation.MainWindow' that matches the specified binding constraints threw an exception.' Line number '4' and line position '9'.
Source=PresentationFramework
InnerException: System.ArgumentNullException
HResult=-2147467261
Message=Value cannot be null.
谢谢你。