thank you for the code snippet.
It works fine, but the text appears not under but above each thumbnail.
And it does not create a new line when the text is larger then the image width.
I tried to find properties or methods but couldn't find anything.
Can you tell me how I could show the text under each thumbnail and let
the text create a newline when it is bigger the the image width?
void MainWindow()
{
...
// increase the thumbnail height, this is necessary for reserving space for text under thumbnail
thumbnailViewer.ThumbnailSize = new Size(thumbnailViewer.ThumbnailSize.Width, thumbnailViewer.ThumbnailSize.Height + 50);
// subscribe to the ThumbnailAdded event
thumbnailViewer1.ThumbnailAdded += new EventHandler<ThumbnailImageItemEventArgs>(thumbnailViewer_ThumbnailAdded);
...
}
void thumbnailViewer_ThumbnailAdded(object sender, ThumbnailImageItemEventArgs e)
{
// reserve space for text
Thickness thumbnailImagePadding = e.Thumbnail.ThumbnailImagePadding;
thumbnailImagePadding.Bottom = 50;
e.Thumbnail.ThumbnailImagePadding = thumbnailImagePadding;
// create the text block with filename
TextBlock text = new TextBlock();
text.Text = e.Thumbnail.Source.SourceInfo.Filename;
text.TextAlignment = TextAlignment.Center;
text.TextWrapping = TextWrapping.Wrap;
text.Margin = new Thickness(0, e.Thumbnail.Height - 50, 0, 0);
// add text block as content of thumbnail
e.Thumbnail.Content = text;
}