public static ImageSource GetImageSource(Uri uri, Dispatcher dispatcher) { if (uri == null) return null; BitmapImage bi = null; BackgroundHelper.DoWithDispatcher(dispatcher, () => { try { bi = new BitmapImage(uri); } catch { bi = new BitmapImage(new Uri("/Images/LoadingError.png", UriKind.Relative)); } }); return bi; }
public static ImageSource GetImageSource(Uri uri, Dispatcher dispatcher) { if (uri == null) { return(null); } BitmapImage bi = null; BackgroundHelper.DoWithDispatcher(dispatcher, () => { try { bi = new BitmapImage(uri); } catch { bi = null; } }); return(bi); }
public static ImageSource GetImageSource(Stream stream, Dispatcher dispatcher) { if (stream == null) return null; BitmapImage bi = null; BackgroundHelper.DoWithDispatcher(dispatcher, () => { try { bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = stream; bi.EndInit(); } catch { bi = new BitmapImage(new Uri("/Images/LoadingError.png", UriKind.Relative)); } }); return bi; }
public static ImageSource GetImageSource(Stream stream, Dispatcher dispatcher) { if (stream == null) { return(null); } BitmapImage bi = null; BackgroundHelper.DoWithDispatcher(dispatcher, () => { try { bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = stream; bi.EndInit(); } catch { bi = null; } }); return(bi); }