VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Wpf.UI Namespace / ThumbnailImageItemCaption Class / CaptionFormatted Event
Syntax Example Requirements SeeAlso
In This Topic
CaptionFormatted Event (ThumbnailImageItemCaption)
In This Topic
Occurs when caption text is formatted.
Syntax
Example

This C#/VB.NET code shows how to customize the thumbnail caption:


''' <summary>
''' Sets the custom thumbnail caption.
''' </summary>
''' <param name="thumbnailViewer">The thumbnail viewer.</param>
Public Shared Sub SetCustomThumbnailCaption(thumbnailViewer As Vintasoft.Imaging.Wpf.UI.WpfThumbnailViewer)
    AddHandler thumbnailViewer.ThumbnailCaption.CaptionFormatted, AddressOf ThumbnailCaption_CaptionFormatted
    thumbnailViewer.ThumbnailCaption.IsVisible = True
End Sub

''' <summary>
''' Handles the CaptionFormatted event of the ThumbnailCaption.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="Vintasoft.Imaging.Wpf.UI.ThumbnailImageItemCaptionFormattedEventArgs"/> instance containing the event data.</param>
Private Shared Sub ThumbnailCaption_CaptionFormatted(sender As Object, e As Vintasoft.Imaging.Wpf.UI.ThumbnailImageItemCaptionFormattedEventArgs)
    Dim image As Vintasoft.Imaging.VintasoftImage = e.Thumbnail.Source
    Dim imageIndex As Integer = e.ThumbnailViewer.Images.IndexOf(image)
    If e.ThumbnailViewer.SelectedThumbnails.Contains(e.Thumbnail) Then
        e.Caption = "Selected"
    Else
        e.Caption = String.Format("{0}, page {1}", System.IO.Path.GetFileName(image.SourceInfo.Filename), image.SourceInfo.PageIndex + 1)
    End If
End Sub


/// <summary>
/// Sets the custom thumbnail caption.
/// </summary>
/// <param name="thumbnailViewer">The thumbnail viewer.</param>
public static void SetCustomThumbnailCaption(Vintasoft.Imaging.Wpf.UI.WpfThumbnailViewer thumbnailViewer)
{
    thumbnailViewer.ThumbnailCaption.CaptionFormatted += ThumbnailCaption_CaptionFormatted;
    thumbnailViewer.ThumbnailCaption.IsVisible = true;
}

/// <summary>
/// Handles the CaptionFormatted event of the ThumbnailCaption.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="Vintasoft.Imaging.Wpf.UI.ThumbnailImageItemCaptionFormattedEventArgs"/> instance containing the event data.</param>
private static void ThumbnailCaption_CaptionFormatted(object sender, Vintasoft.Imaging.Wpf.UI.ThumbnailImageItemCaptionFormattedEventArgs e)
{
    Vintasoft.Imaging.VintasoftImage image = e.Thumbnail.Source;
    int imageIndex = e.ThumbnailViewer.Images.IndexOf(image);
    if (e.ThumbnailViewer.SelectedThumbnails.Contains(e.Thumbnail))
    {
        e.Caption = "Selected";
    }
    else
    {
        e.Caption = string.Format("{0}, page {1}", System.IO.Path.GetFileName(image.SourceInfo.Filename), image.SourceInfo.PageIndex + 1);
    }
}

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also