Essentially you have been drawing nulls. The older style of bitmaps do not really travel that well into WPF. You can change this code...
sep s = new sep();
s.title = item.title;
s.thumbnail = (System.Drawing.Image)GetThumbImage(item.urlsite);
to this...
Sep sep = new Sep();
sep.Title = "title";
var bmp = GetThumbImage("xxx");
using (MemoryStream memory = new MemoryStream())
{
bmp.Save(memory, ImageFormat.Png);
memory.Position = 0;
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
sep.ThumbnailImage = bitmapImage;
}
This code runs an ad-hoc conversion on the Bitmap so that it can be used as a WPF ImageSource.
The 'sep' class is declared with an ImageSource like this...
public class Sep : INotifyPropertyChanged
{
private string _title;
public string Title
{
[DebuggerStepThrough]
get { return _title; }
[DebuggerStepThrough]
set
{
if (value != _title)
{
_title = value;
OnPropertyChanged("Title");
}
}
}
private ImageSource _thumbnailImage;
public ImageSource ThumbnailImage
{
[DebuggerStepThrough]
get { return _thumbnailImage; }
[DebuggerStepThrough]
set
{
if (value != _thumbnailImage)
{
_thumbnailImage = value;
OnPropertyChanged("ThumbnailImage");
}
}
}
#region INotifyPropertyChanged Implementation
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string name)
{
var handler = System.Threading.Interlocked.CompareExchange(ref PropertyChanged, null, null);
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
In the longer run, you can consider refactoring the conversion into an IValueConverter.