private void AttachBitmapSourceEvents(BitmapSource bitmapSource) { DownloadCompletedEventManager.AddHandler(bitmapSource, OnSourceDownloaded); DownloadFailedEventManager.AddHandler(bitmapSource, OnSourceFailed); DecodeFailedEventManager.AddHandler(bitmapSource, OnSourceFailed); _bitmapSource = bitmapSource; }
private void DetachBitmapSourceEvents() { if (_bitmapSource != null) { DownloadCompletedEventManager.RemoveHandler(_bitmapSource, OnSourceDownloaded); DownloadFailedEventManager.RemoveHandler(_bitmapSource, OnSourceFailed); DecodeFailedEventManager.RemoveHandler(_bitmapSource, OnSourceFailed); _bitmapSource = null; } }