Class PreviewTemplateContext
Inherited Members
Namespace: Syncfusion.Blazor.InteractiveChat
Assembly: Syncfusion.Blazor.dll
Syntax
public class PreviewTemplateContext
Constructors
PreviewTemplateContext()
Declaration
public PreviewTemplateContext()
Properties
Index
Gets or sets the zero-based index of the currently selected file used to update the preview template.
Declaration
public int Index { get; set; }
Property Value
| Type | Description |
|---|---|
| int | An int representing the index of the active file within SelectedFile.
The default value is |
Remarks
Use this property to synchronize which file’s details are displayed in a preview template (for example, when a user clicks a thumbnail from a list of selected files).
Valid values range from 0 to SelectedFile.Count - 1. Values outside this range should be treated as -1 (no selection) or ignored by the component.
When updated, the component should resolve the corresponding FileInfo from SelectedFile and refresh the bound PreviewTemplate.
SelectedFile
Gets the file information for the attachment currently being rendered in a custom template.
Declaration
public FileInfo SelectedFile { get; set; }
Property Value
| Type | Description |
|---|---|
| FileInfo | The FileInfo object for the current attachment in the template's rendering context. This property is read-only and its value is determined by the parent component. |
Remarks
This property is implicitly available as the context variable within templates such as PreviewTemplate.
It provides access to the attachment's metadata, including its Name, Size, and FileSource, enabling fully custom UI rendering for each attachment.
Examples
The following example demonstrates how to use the implicit context object within a PreviewTemplate to create a custom layout for each selected file.
<SfChatUI>
<PreviewTemplate>
@{
var fileContext = context as FileInfo;
if (fileContext != null)
{
<div class="custom-attachment-preview">
<span class="file-icon">📁</span>
<div class="file-details">
<span class="file-name">@fileContext.Name</span>
<span class="file-size">@((fileContext.Size / 1024.0).ToString("F2")) KB</span>
</div>
</div>
}
}
</PreviewTemplate>
</SfChatUI>